lib/pulse_meter/sensor/configuration.rb
# Tries to create a specific sensor
# @param name [Symbol] sensor name
# @param opts [Hash] sensor options
Tries to create a specific sensor
Tries to create a specific sensor
def create_sensor(name, opts)
        sensor_type = opts.respond_to?(:sensor_type) ? opts.sensor_type : opts[:sensor_type]
        klass_s = sensor_class(sensor_type)
        klass = constantize(klass_s)
        raise ArgumentError, "#{klass_s} is not a valid class for a sensor" unless klass
        args = (opts.respond_to?(:args) ? opts.args : opts[:args]) || {}
        klass.new(name, symbolize_keys(args.to_hash))
      end
def create_sensor ( name , opts ) sensor_type = opts . respond_to? ( :sensor_type ) ? opts . sensor_type : opts [ :sensor_type ] klass_s = sensor_class ( sensor_type ) klass = constantize ( klass_s ) raise ArgumentError , "#{klass_s} is not a valid class for a sensor" unless klass args = ( opts . respond_to? ( :args ) ? opts . args : opts [ :args ] ) || { } klass . new ( name , symbolize_keys ( args . to_hash ) ) end
Tries to create a specific sensor
Tries to create a specific sensor
name
None
opts
None