Class: Property
- Inherits:
-
Object
- Object
- Property
- Defined in:
- lib/cisco-deviot/thing.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #default_value_for(type) ⇒ Object
- #get_model ⇒ Object
-
#initialize(name, type = PROPERTY_TYPE_INT, value = nil, unit = '', range = nil, description = '') ⇒ Property
constructor
A new instance of Property.
Constructor Details
#initialize(name, type = PROPERTY_TYPE_INT, value = nil, unit = '', range = nil, description = '') ⇒ Property
Returns a new instance of Property.
28 29 30 31 32 33 34 35 |
# File 'lib/cisco-deviot/thing.rb', line 28 def initialize(name, type = PROPERTY_TYPE_INT, value = nil, unit = '', range = nil, description = '') @name = name @type = type @value = value @unit = unit @range = range @description = description end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
26 27 28 |
# File 'lib/cisco-deviot/thing.rb', line 26 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/cisco-deviot/thing.rb', line 21 def name @name end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
25 26 27 |
# File 'lib/cisco-deviot/thing.rb', line 25 def range @range end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/cisco-deviot/thing.rb', line 22 def type @type end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
24 25 26 |
# File 'lib/cisco-deviot/thing.rb', line 24 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
23 24 25 |
# File 'lib/cisco-deviot/thing.rb', line 23 def value @value end |
Instance Method Details
#default_value_for(type) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cisco-deviot/thing.rb', line 37 def default_value_for(type) case type when PROPERTY_TYPE_INT return 0 when PROPERTY_TYPE_STRING return '' when PROPERTY_TYPE_BOOL return FALSE when PROPERTY_TYPE_COLOR return 'FFFFFF' else return nil end end |
#get_model ⇒ Object
52 53 54 55 |
# File 'lib/cisco-deviot/thing.rb', line 52 def get_model {name: @name, type: @type, value: @value, range: @range, unit: @unit, description: @description} end |