Class: Hue::Bulb

Inherits:
Object
  • Object
show all
Includes:
Indentation
Defined in:
lib/hue/extensions/bulb.rb

Constant Summary

Constants included from Indentation

Indentation::DEFAULT_INDENTATION_SIZE

Instance Method Summary collapse

Methods included from Indentation

#indent, #puts

Instance Method Details



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hue/extensions/bulb.rb', line 7

def print_state
  spaces = 4
  puts "#{self.id}.".ljust(spaces) + "#{self.name}: #{self.on? ? 'ON' : 'OFF'}"
  indent(spaces) do
    puts "Brightness: #{self.brightness} (#{(self.brightness_percent).to_i}%)"
    puts "Color: #{self.color}, #{self.color.to_rgb}" if self.state["hue"]
    transitory_state = [
      (self.transition_time > 0 ? "Transition time: #{self.transition_time} sec" : nil),
      (self.blinking? ? 'Alert: Blinking!' : nil),
      (self.effect? ? "Effect: #{self.effect}" : nil),
    ].compact
    puts transitory_state.join(", ") unless transitory_state.empty?
  end
end