Class: Songbook::RenderSong

Inherits:
Object
  • Object
show all
Defined in:
lib/songbook/render_song.rb

Constant Summary collapse

SEPARATOR =
[nil, nil].freeze
TABLE_WIDTH =
80
LYRICS_CHORDS_SEPARATOR =
'   '

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(song) ⇒ RenderSong

Returns a new instance of RenderSong.



13
14
15
# File 'lib/songbook/render_song.rb', line 13

def initialize(song)
  @song = song
end

Instance Attribute Details

#songObject (readonly)

Returns the value of attribute song.



11
12
13
# File 'lib/songbook/render_song.rb', line 11

def song
  @song
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
# File 'lib/songbook/render_song.rb', line 17

def call
  result = <<~RESULT
    #{song.title}\n
    #{song.details}
    #{verses_table}
  RESULT

  result.split("\n").map(&:rstrip).join("\n")
end