Class: Huebot::Program
- Inherits:
-
Object
- Object
- Huebot::Program
- Defined in:
- lib/huebot/program.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#data ⇒ Object
Returns the value of attribute data.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#device_refs(node = data) ⇒ Object
Returns all device refs (e.g. $all, $1, $2) in the program.
- #errors(node = data) ⇒ Object
-
#group_names(node = data) ⇒ Object
Returns all group names hard-coded into the program.
-
#light_names(node = data) ⇒ Object
Returns all light names hard-coded into the program.
- #valid? ⇒ Boolean
- #warnings(node = data) ⇒ Object
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
38 39 40 |
# File 'lib/huebot/program.rb', line 38 def api_version @api_version end |
#data ⇒ Object
Returns the value of attribute data.
39 40 41 |
# File 'lib/huebot/program.rb', line 39 def data @data end |
#name ⇒ Object
Returns the value of attribute name.
37 38 39 |
# File 'lib/huebot/program.rb', line 37 def name @name end |
Instance Method Details
#device_refs(node = data) ⇒ Object
Returns all device refs (e.g. $all, $1, $2) in the program
56 57 58 |
# File 'lib/huebot/program.rb', line 56 def device_refs(node = data) devices(AST::DeviceRef).uniq.map(&:ref) end |
#errors(node = data) ⇒ Object
60 61 62 63 64 |
# File 'lib/huebot/program.rb', line 60 def errors(node = data) node.children.reduce(node.errors) { |acc, child| acc + errors(child) } end |
#group_names(node = data) ⇒ Object
Returns all group names hard-coded into the program
51 52 53 |
# File 'lib/huebot/program.rb', line 51 def group_names(node = data) devices(AST::Group).uniq.map(&:name) end |
#light_names(node = data) ⇒ Object
Returns all light names hard-coded into the program
46 47 48 |
# File 'lib/huebot/program.rb', line 46 def light_names(node = data) devices(AST::Light).uniq.map(&:name) end |
#valid? ⇒ Boolean
41 42 43 |
# File 'lib/huebot/program.rb', line 41 def valid? errors.empty? end |
#warnings(node = data) ⇒ Object
66 67 68 69 70 |
# File 'lib/huebot/program.rb', line 66 def warnings(node = data) node.children.reduce(node.warnings) { |acc, child| acc + warnings(child) } end |