Class: Huebot::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/huebot/program.rb

Defined Under Namespace

Modules: AST Classes: Src

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_versionObject

Returns the value of attribute api_version.



35
36
37
# File 'lib/huebot/program.rb', line 35

def api_version
  @api_version
end

#dataObject

Returns the value of attribute data.



36
37
38
# File 'lib/huebot/program.rb', line 36

def data
  @data
end

#nameObject

Returns the value of attribute name.



34
35
36
# File 'lib/huebot/program.rb', line 34

def name
  @name
end

Instance Method Details

#device_refs(node = data) ⇒ Object

Returns all device refs (e.g. $all, $1, $2) in the program



53
54
55
# File 'lib/huebot/program.rb', line 53

def device_refs(node = data)
  devices(AST::DeviceRef).uniq.map(&:ref)
end

#errors(node = data) ⇒ Object



57
58
59
60
61
# File 'lib/huebot/program.rb', line 57

def errors(node = data)
  node.children.reduce(node.errors) { |errors, child|
    errors + child.errors
  }
end

#group_names(node = data) ⇒ Object

Returns all group names hard-coded into the program



48
49
50
# File 'lib/huebot/program.rb', line 48

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



43
44
45
# File 'lib/huebot/program.rb', line 43

def light_names(node = data)
  devices(AST::Light).uniq.map(&:name)
end

#valid?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/huebot/program.rb', line 38

def valid?
  errors.empty?
end

#warnings(node = data) ⇒ Object



63
64
65
66
67
# File 'lib/huebot/program.rb', line 63

def warnings(node = data)
  node.children.reduce(node.warnings) { |warnings, child|
    warnings + child.warnings
  }
end