Class: EhbrsRubyUtils::Music::LyricsBook::Song

Inherits:
Resource
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/music/lyrics_book/song.rb

Constant Summary collapse

DEFAULT_TITLE =
'Unknown title'

Instance Attribute Summary

Attributes inherited from Resource

#previous

Instance Method Summary collapse

Methods inherited from Resource

#<=>, create_list, #filename, #header_id, #header_index, #index_id, #link_to_header, #output_index, #output_main, #type

Instance Method Details

#albumObject



14
15
16
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 14

def album
  parent
end

#cached_lyricsObject



36
37
38
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 36

def cached_lyrics
  ::YAML.load_file(lyrics_cache.content_path)
end

#fs_object_idArray<String>

Returns Array<String>.

Returns:

  • (Array<String>)

    Array<String>



19
20
21
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 19

def fs_object_id
  %w[artist album title].map { |k| tag.send(k) }
end

#header_titleObject



40
41
42
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 40

def header_title
  "#{number} - #{title}"
end

#lyricsObject



23
24
25
26
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 23

def lyrics
  fetch_lyrics unless lyrics_cached?
  cached_lyrics
end

#lyrics_cached?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 32

def lyrics_cached?
  lyrics_cache.stored?
end

#titleObject



44
45
46
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 44

def title
  tag.if_present(DEFAULT_TITLE, &:title)
end

#valid?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 28

def valid?
  tag.present?
end