Class: Songbook::Song

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, details:, chords:, lyrics:) ⇒ Song

Returns a new instance of Song.



9
10
11
12
13
14
# File 'lib/songbook/song.rb', line 9

def initialize(title:, details:, chords:, lyrics:)
  @title = title
  @details = details
  @chords = chords
  @lyrics = lyrics
end

Instance Attribute Details

#chordsObject (readonly)

Returns the value of attribute chords.



7
8
9
# File 'lib/songbook/song.rb', line 7

def chords
  @chords
end

#detailsObject (readonly)

Returns the value of attribute details.



7
8
9
# File 'lib/songbook/song.rb', line 7

def details
  @details
end

#lyricsObject (readonly)

Returns the value of attribute lyrics.



7
8
9
# File 'lib/songbook/song.rb', line 7

def lyrics
  @lyrics
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/songbook/song.rb', line 7

def title
  @title
end

Instance Method Details

#versesObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/songbook/song.rb', line 16

def verses
  lyrics.map do |lyrics_verse|
    verse_title = find_verse_title(lyrics_verse)
    verse_lyrics = find_verse_lyrics(lyrics_verse)

    Verse.new(
      title: verse_title,
      lyrics: verse_lyrics,
      chords: chords[verse_title]
    )
  end
end