Class: FortuneTeller::ListRenderer
- Inherits:
-
Object
- Object
- FortuneTeller::ListRenderer
- Defined in:
- lib/fortune_teller/list_renderer.rb
Instance Attribute Summary collapse
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ListRenderer
constructor
A new instance of ListRenderer.
- #render(text_array) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ListRenderer
Returns a new instance of ListRenderer.
4 5 6 |
# File 'lib/fortune_teller/list_renderer.rb', line 4 def initialize( = {} ) @separator = [:separator] || "\n" end |
Instance Attribute Details
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
3 4 5 |
# File 'lib/fortune_teller/list_renderer.rb', line 3 def separator @separator end |
Instance Method Details
#render(text_array) ⇒ Object
8 9 10 11 |
# File 'lib/fortune_teller/list_renderer.rb', line 8 def render( text_array ) "Pick one (i.e. type it, then press enter):\n" + text_array.map(&:to_s).join( separator ) + "\n" end |