Class: MQTT::Homie::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mqtt/homie/base.rb

Direct Known Subclasses

Device, Node, Property

Constant Summary collapse

REGEX =
"[a-z0-9][a-z0-9\-]*"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/mqtt/homie/base.rb', line 10

def initialize(id, name)
  raise ArgumentError, "Invalid Homie ID '#{id}'" unless id.is_a?(String) && id =~ Regexp.new("^#{REGEX}$")

  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/mqtt/homie/base.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/mqtt/homie/base.rb', line 8

def name
  @name
end