Class: MotionTrigger

Inherits:
Object
  • Object
show all
Defined in:
lib/macrohub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location: nil) ⇒ MotionTrigger

Returns a new instance of MotionTrigger.



73
74
75
76
77
78
# File 'lib/macrohub.rb', line 73

def initialize(location: nil)
  
  @location = location
  @type = :motion
  
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



71
72
73
# File 'lib/macrohub.rb', line 71

def location
  @location
end

#typeObject (readonly)

Returns the value of attribute type.



71
72
73
# File 'lib/macrohub.rb', line 71

def type
  @type
end

Instance Method Details

#match?(detail) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/macrohub.rb', line 80

def match?(detail)

  puts 'inside MotionTrigger#match' if $debug
  location = detail[:location]
  
  if location then
    
    @location.downcase == location.downcase
    
  else
    return false
  end
  
end

#to_nodeObject



95
96
97
98
# File 'lib/macrohub.rb', line 95

def to_node()
  Rexle::Element.new(:trigger, attributes: {type: :motion, 
                                            location: @location})
end

#to_rowxObject



100
101
102
# File 'lib/macrohub.rb', line 100

def to_rowx()
  "trigger: Motion detected in the %s" %  @location
end