Class: Insnergy::Widget
- Inherits:
-
Object
- Object
- Insnergy::Widget
- Defined in:
- lib/insnergy-api-ruby-client.rb
Instance Attribute Summary collapse
-
#new_infos ⇒ Object
readonly
Returns the value of attribute new_infos.
-
#widget_alias ⇒ Object
readonly
Returns the value of attribute widget_alias.
-
#widget_dev_id ⇒ Object
readonly
Returns the value of attribute widget_dev_id.
-
#widget_dev_type_name ⇒ Object
readonly
Returns the value of attribute widget_dev_type_name.
-
#widget_status ⇒ Object
readonly
Returns the value of attribute widget_status.
Instance Method Summary collapse
- #co2_meter ⇒ Object
- #co_meter ⇒ Object
-
#initialize(opts = {}) ⇒ Widget
constructor
A new instance of Widget.
- #sensor_th_hy ⇒ Object
- #widget_info_value ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Widget
Returns a new instance of Widget.
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/insnergy-api-ruby-client.rb', line 127 def initialize(opts = {}) @infos = Hash.new @new_infos = Hash.new @widget_dev_id = opts['dev_id'] @widget_dev_type_name = opts['dev_type_name'] @widget_alias = opts['alias'] @widget_status = opts['status'] opts['widget_infos'].each do |ele| @new_infos[ele['info_desc']] = { id: ele['info_id'], name: ele['info_name'], value: ele['info_value']} @infos[ele['info_name']] = ele['info_value'] end end |
Instance Attribute Details
#new_infos ⇒ Object (readonly)
Returns the value of attribute new_infos.
125 126 127 |
# File 'lib/insnergy-api-ruby-client.rb', line 125 def new_infos @new_infos end |
#widget_alias ⇒ Object (readonly)
Returns the value of attribute widget_alias.
125 126 127 |
# File 'lib/insnergy-api-ruby-client.rb', line 125 def @widget_alias end |
#widget_dev_id ⇒ Object (readonly)
Returns the value of attribute widget_dev_id.
125 126 127 |
# File 'lib/insnergy-api-ruby-client.rb', line 125 def @widget_dev_id end |
#widget_dev_type_name ⇒ Object (readonly)
Returns the value of attribute widget_dev_type_name.
125 126 127 |
# File 'lib/insnergy-api-ruby-client.rb', line 125 def @widget_dev_type_name end |
#widget_status ⇒ Object (readonly)
Returns the value of attribute widget_status.
125 126 127 |
# File 'lib/insnergy-api-ruby-client.rb', line 125 def @widget_status end |
Instance Method Details
#co2_meter ⇒ Object
148 149 150 |
# File 'lib/insnergy-api-ruby-client.rb', line 148 def co2_meter @infos['400600'] end |
#co_meter ⇒ Object
144 145 146 |
# File 'lib/insnergy-api-ruby-client.rb', line 144 def co_meter @infos['400700'] end |
#sensor_th_hy ⇒ Object
152 153 154 |
# File 'lib/insnergy-api-ruby-client.rb', line 152 def sensor_th_hy "#{@infos['400100']}|#{@infos['400200']}" end |
#widget_info_value ⇒ Object
140 141 142 |
# File 'lib/insnergy-api-ruby-client.rb', line 140 def self.send(:"#{@widget_dev_type_name.downcase}") end |