Class: FortuneTeller::ListRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/fortune_teller/list_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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( options = {} )
  @separator = options[:separator] || "\n"
end

Instance Attribute Details

#separatorObject (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