Class: MQTT::Homie::DeviceBuilder
- Inherits:
-
Object
- Object
- MQTT::Homie::DeviceBuilder
- Defined in:
- lib/mqtt/homie/device_builder.rb
Instance Method Summary collapse
-
#build ⇒ Object
create device and return it.
-
#initialize(options = {}) ⇒ DeviceBuilder
constructor
A new instance of DeviceBuilder.
- #node(options = {}) ⇒ Object
- #property(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DeviceBuilder
Returns a new instance of DeviceBuilder.
4 5 6 7 |
# File 'lib/mqtt/homie/device_builder.rb', line 4 def initialize( = {}) @nodes = [] @device_options = end |
Instance Method Details
#build ⇒ Object
create device and return it
10 11 12 13 |
# File 'lib/mqtt/homie/device_builder.rb', line 10 def build build_node if @node_data MQTT::Homie::Device.new(@device_options.merge(nodes: @nodes)) end |
#node(options = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/mqtt/homie/device_builder.rb', line 15 def node( = {}) raise "node key/value list expected" unless .kind_of?(Hash) build_node if @node_data @node_data = @properties = [] self end |