Class: Rule

Inherits:
HObject show all
Defined in:
lib/lights/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HObject

#to_json

Constructor Details

#initialize(id = nil, data = {}) ⇒ Rule

Returns a new instance of Rule.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lights/rule.rb', line 7

def initialize( id = nil, data = {} )
  @id = id
  @name = data["name"]
  @owner = data["owner"]
  @created = data["created"]
  @last_triggered = data["lasttriggered"]
  @times_triggered = data["timestriggered"]
  @status = data["status"]
  @conditions = data["conditions"]
  @actions = data["actions"]
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



4
5
6
# File 'lib/lights/rule.rb', line 4

def actions
  @actions
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



4
5
6
# File 'lib/lights/rule.rb', line 4

def conditions
  @conditions
end

#createdObject (readonly)

Returns the value of attribute created.



4
5
6
# File 'lib/lights/rule.rb', line 4

def created
  @created
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/lights/rule.rb', line 4

def id
  @id
end

#last_triggeredObject (readonly)

Returns the value of attribute last_triggered.



4
5
6
# File 'lib/lights/rule.rb', line 4

def last_triggered
  @last_triggered
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/lights/rule.rb', line 4

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



4
5
6
# File 'lib/lights/rule.rb', line 4

def owner
  @owner
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/lights/rule.rb', line 4

def status
  @status
end

#times_triggeredObject (readonly)

Returns the value of attribute times_triggered.



4
5
6
# File 'lib/lights/rule.rb', line 4

def times_triggered
  @times_triggered
end

Instance Method Details

#dataObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lights/rule.rb', line 19

def data
  data = {}
  data["name"] = @name if @name
  data["owner"] = @owner if @owner
  data["created"] = @created if @created
  data["lasttriggered"] = @last_triggered if @last_triggered
  data["timestriggered"] = @times_triggered if @times_triggered
  data["status"] = @status if @status
  data["conditions"] = @conditions if @conditions
  data["actions"] = @actions if @actions
  data
end