Class: Xsay::Render
- Inherits:
-
Object
- Object
- Xsay::Render
- Defined in:
- lib/xsay/render.rb
Instance Attribute Summary collapse
-
#colour ⇒ Object
readonly
Returns the value of attribute colour.
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#speed ⇒ Object
readonly
Returns the value of attribute speed.
Instance Method Summary collapse
- #each_frame ⇒ Object
-
#initialize(colour: options[:colour].to_sym, distance: options[:distance], speed: options[:speed]) ⇒ Render
constructor
A new instance of Render.
- #render(message, template) ⇒ Object
Constructor Details
#initialize(colour: options[:colour].to_sym, distance: options[:distance], speed: options[:speed]) ⇒ Render
Returns a new instance of Render.
5 6 7 8 9 10 11 12 13 |
# File 'lib/xsay/render.rb', line 5 def initialize( colour: [:colour].to_sym, distance: [:distance], speed: [:speed] ) @colour = colour.to_sym @distance = distance @speed = speed end |
Instance Attribute Details
#colour ⇒ Object (readonly)
Returns the value of attribute colour.
3 4 5 |
# File 'lib/xsay/render.rb', line 3 def colour @colour end |
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
3 4 5 |
# File 'lib/xsay/render.rb', line 3 def distance @distance end |
#speed ⇒ Object (readonly)
Returns the value of attribute speed.
3 4 5 |
# File 'lib/xsay/render.rb', line 3 def speed @speed end |
Instance Method Details
#each_frame ⇒ Object
24 25 26 27 28 |
# File 'lib/xsay/render.rb', line 24 def each_frame return yield 0 unless move? frames = distance.downto(0).to_a + 0.upto(distance).to_a frames.each { |x| yield x } end |
#render(message, template) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/xsay/render.rb', line 15 def render(, template) = .join(' ') if .respond_to?(:join) line_break = "-" * .length each_frame do |frame| draw(, template, line_break, frame) end nil end |