Sha256: 5631ced09cf4dd5cc781017dc9214d95c814ce91b44d5e4150401ab81ccb3757

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

require 'ws_light/set/color_set'

module WSLight
  module Set
    # Creates a set with all random colors
    class SunnySet < ColorSet
      def frame
        @set ||= generate_set
      end

      def pixel(number, _frame = 0)
        frame[number]
      end

      def generate_set
        set = []
        position = sun_position
        @full_length.times do |i|
          set << if position.include?(i)
                   Color.by_name(:yellow)
                 else
                   Color.by_name(:blue)
                 end
        end
        set
      end

      def sun_position
        case rand(4)
        when 0
          10..40
        when 1
          140..170
        when 2
          190..220
        else
          300..330
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ws_light-0.4.2 lib/ws_light/set/weather/sunny_set.rb