Class: Thing
- Inherits:
-
Object
- Object
- Thing
- Defined in:
- lib/cisco-deviot/thing.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #add_action(action) ⇒ Object
- #add_property(property) ⇒ Object
- #get_model ⇒ Object
-
#initialize(id, name, kind) ⇒ Thing
constructor
A new instance of Thing.
- #to_s ⇒ Object
Constructor Details
#initialize(id, name, kind) ⇒ Thing
Returns a new instance of Thing.
93 94 95 96 97 98 99 |
# File 'lib/cisco-deviot/thing.rb', line 93 def initialize(id, name, kind) @id = id @name = name @kind = kind @properties = [] @actions = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
91 92 93 |
# File 'lib/cisco-deviot/thing.rb', line 91 def actions @actions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
87 88 89 |
# File 'lib/cisco-deviot/thing.rb', line 87 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
89 90 91 |
# File 'lib/cisco-deviot/thing.rb', line 89 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
88 89 90 |
# File 'lib/cisco-deviot/thing.rb', line 88 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
90 91 92 |
# File 'lib/cisco-deviot/thing.rb', line 90 def properties @properties end |
Instance Method Details
#add_action(action) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/cisco-deviot/thing.rb', line 113 def add_action(action) if action.instance_of? String @actions.push(Property.new(action)) return self end if action.instance_of? Action @actions.push(action) return self end raise ArgumentError end |
#add_property(property) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/cisco-deviot/thing.rb', line 101 def add_property(property) if property.instance_of? String @properties.push(Property.new(property)) return self end if property.instance_of? Property @properties.push(property) return self end raise ArgumentError end |
#get_model ⇒ Object
129 130 131 132 |
# File 'lib/cisco-deviot/thing.rb', line 129 def get_model {id: @id, name: @name, kind: @kind, properties: @properties.collect {|p| p.get_model}, actions: @actions.collect {|p| p.get_model}} end |
#to_s ⇒ Object
125 126 127 |
# File 'lib/cisco-deviot/thing.rb', line 125 def to_s "#{@id}[#{@name}(#{@kind})]" end |