Sha256: f9d69a3ebdf758bc5c5923ce370825c707239c668645500b2fc54f1aac1474cb

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

require 'yaml'

class Lamp
  attr_accessor :id,:hue,:saturation,:brightness,:is_on, :transition_time, :colors

  DEFAULT_COLORS_FILE = "#{File.expand_path(File.dirname(__FILE__))}/data/default_colors.yml"
  DEFAULT_COLORS = YAML.load_file(DEFAULT_COLORS_FILE)['colors']

  def initialize(lamp_id)
    @is_on = true
    @id = lamp_id
    @hue = 0
    @saturation = 254
    @brightness = 10
    @transition_time = 0
    @colors = DEFAULT_COLORS
  end

  def color= color
    raise "unknown color of #{color}" if @colors[color].nil?

    @hue = @colors[color]['hue']
    @saturation = @colors[color]['saturation']
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_driven_lighting-1.1.0 lib/test_driven_lighting/lamp.rb