Class: ColorWave
- Inherits:
-
Object
- Object
- ColorWave
- Defined in:
- lib/color_wave/version.rb,
lib/color_wave/color_wave.rb
Constant Summary collapse
- VERSION =
'0.1.0'
- DEFAULT_LINES =
20
- DEFAULT_CHARS =
%w( O ).freeze
- DEFAULT_CYCLES =
3
- DEFAULT_SPEED =
10.0
- DEFAULT_COLORS =
rainbow RGB values stolen from Term-Colormap on CPAN metacpan.org/source/XXFELIXXX/Term-Colormap-0.06/lib/Term/Colormap.pm
%w( 800000 ff0000 ff5f00 ff8700 ffaf00 ffd700 ffff00 ffff00 d7ff00 afff00 87ff00 5fff00 00ff00 00ff00 00ff5f 00ff87 00ffaf 00ffd7 00ffff 00ffff 00d7ff 00afff 0087ff 005fff 0000ff 0000ff 5f00ff 8700ff af00ff d700ff ff00ff 800080 ).freeze
- TWO_PI =
Math::PI * 2
- BASE_SLEEP_TIME =
0.001
Instance Attribute Summary collapse
-
#chars ⇒ Object
readonly
Returns the value of attribute chars.
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#speed ⇒ Object
readonly
Returns the value of attribute speed.
Instance Method Summary collapse
-
#initialize(lines: DEFAULT_LINES, cycles: DEFAULT_CYCLES, chars: DEFAULT_CHARS, colors: DEFAULT_COLORS, speed: DEFAULT_SPEED) ⇒ ColorWave
constructor
A new instance of ColorWave.
- #run ⇒ Object
Constructor Details
#initialize(lines: DEFAULT_LINES, cycles: DEFAULT_CYCLES, chars: DEFAULT_CHARS, colors: DEFAULT_COLORS, speed: DEFAULT_SPEED) ⇒ ColorWave
Returns a new instance of ColorWave.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/color_wave/color_wave.rb', line 27 def initialize(lines: DEFAULT_LINES, cycles: DEFAULT_CYCLES, chars: DEFAULT_CHARS, colors: DEFAULT_COLORS, speed: DEFAULT_SPEED) @lines = lines @cycles = cycles @chars = chars.cycle @colors = colors.cycle @speed = speed @current_line = 0 @shutdown = false set_signal_handlers recalculate_values end |
Instance Attribute Details
#chars ⇒ Object (readonly)
Returns the value of attribute chars.
25 26 27 |
# File 'lib/color_wave/color_wave.rb', line 25 def chars @chars end |
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
25 26 27 |
# File 'lib/color_wave/color_wave.rb', line 25 def colors @colors end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
25 26 27 |
# File 'lib/color_wave/color_wave.rb', line 25 def lines @lines end |
#speed ⇒ Object (readonly)
Returns the value of attribute speed.
25 26 27 |
# File 'lib/color_wave/color_wave.rb', line 25 def speed @speed end |
Instance Method Details
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/color_wave/color_wave.rb', line 43 def run self.shutdown = false prepare_screen loop.each_with_index do |_, pass| break if shutdown write_one_pass pass ready_next_pass end cleanup_screen end |