Class: HomeAssistant::Generator::Component
- Inherits:
-
Object
- Object
- HomeAssistant::Generator::Component
- Defined in:
- lib/home_assistant/generator/component.rb
Overview
generic home-assistant component
Instance Attribute Summary collapse
-
#component_class ⇒ Object
Returns the value of attribute component_class.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(name) ⇒ Component
constructor
A new instance of Component.
- #method_missing(name, *args) ⇒ Object
- #name_property ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name) ⇒ Component
Returns a new instance of Component.
9 10 11 12 |
# File 'lib/home_assistant/generator/component.rb', line 9 def initialize(name) @properties = Mash.new send(name_property, name) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/home_assistant/generator/component.rb', line 22 def method_missing(name, *args) super unless args.one? properties[name.to_sym] = case args.first when Symbol args.first.to_s else args.first end end |
Instance Attribute Details
#component_class ⇒ Object
Returns the value of attribute component_class.
8 9 10 |
# File 'lib/home_assistant/generator/component.rb', line 8 def component_class @component_class end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
7 8 9 |
# File 'lib/home_assistant/generator/component.rb', line 7 def properties @properties end |
Instance Method Details
#name_property ⇒ Object
14 15 16 |
# File 'lib/home_assistant/generator/component.rb', line 14 def name_property :name end |
#to_h ⇒ Object
18 19 20 |
# File 'lib/home_assistant/generator/component.rb', line 18 def to_h properties.to_hash end |