Class: ConstraintsNlp
- Inherits:
-
Object
- Object
- ConstraintsNlp
- Includes:
- AppRoutes
- Defined in:
- lib/ruby-macrodroid/macro.rb
Instance Method Summary collapse
- #constraints(params) ⇒ Object
-
#initialize ⇒ ConstraintsNlp
constructor
A new instance of ConstraintsNlp.
Constructor Details
#initialize ⇒ ConstraintsNlp
Returns a new instance of ConstraintsNlp.
330 331 332 333 334 335 336 |
# File 'lib/ruby-macrodroid/macro.rb', line 330 def initialize() super() params = {} constraints(params) end |
Instance Method Details
#constraints(params) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/ruby-macrodroid/macro.rb', line 338 def constraints(params) # Device State get /^Device (locked|unlocked)/i do |state| [DeviceLockedConstraint, {locked: state.downcase == 'locked'}] end get /^airplane mode (.*)/i do |state| [AirplaneModeConstraint, {enabled: (state =~ /^enabled|on$/i) == 0}] end # # -- MacroDroid specific ----------------------------------------------------------------------- get /^(\w+) (=) (\[?\w+\]?)/i do |loperand, operator, roperand| h = { loperand: loperand, operator: operator, roperand: roperand } [MacroDroidVariableConstraint, h] end # -- Sensors ----------------------------------- # get /^Light Sensor (Less|Greater) than (50.0)lx/i do |operator, val| level, option = operator.downcase == 'less' ? [-1,0] : [1,1] h = { light_level: level, light_level_float: val, option: option } [LightLevelConstraint, h] end get /^Proximity Sensor: (Near|Far)/i do |distance| [ProximitySensorConstraint, {near: distance.downcase == 'near'}] end # -- Screen and Speaker --------------------------- # get /^Screen (On|Off)/i do |state| [ScreenOnOffConstraint, {screen_on: state.downcase == 'on'}] end end |