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



17
18
19
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 17

def album
  parent
end

#cached_lyricsObject



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

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

#fs_object_idArray<String>

Returns Array<String>.

Returns:

  • (Array<String>)

    Array<String>



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

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

#header_titleObject



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

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

#lyricsObject



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

def lyrics
  fetch_lyrics unless lyrics_cached?
  cached_lyrics
end

#lyrics_cached?Boolean

Returns:

  • (Boolean)


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

def lyrics_cached?
  lyrics_cache.stored?
end

#titleObject



47
48
49
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/song.rb', line 47

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

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  tag.present?
end