Class: LightLevelConstraint

Inherits:
Constraint show all
Defined in:
lib/ruby-macrodroid/constraints.rb

Overview

Category: Sensors

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Constraint

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ LightLevelConstraint

Returns a new instance of LightLevelConstraint.



1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
# File 'lib/ruby-macrodroid/constraints.rb', line 1308

def initialize(h={})

  options = {
    light_level: -1,
    light_level_float: 5000.0,
    option: 1
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object



1320
1321
1322
1323
1324
1325
1326
# File 'lib/ruby-macrodroid/constraints.rb', line 1320

def to_s(colour: false, indent: 0)
  
  operator = @h[:light_level] == -1 ? 'Less than' : 'Greater than'    
  condition = operator + ' ' + @h[:light_level_float].to_s + 'lx'
  'Light Sensor ' + condition
  
end