Sha256: 8353f340d2d4a8b19c209274a6b16a2a4e65959b53d86b6d941388794b91da23

Contents?: true

Size: 996 Bytes

Versions: 33

Compression:

Stored size: 996 Bytes

Contents

# frozen_string_literal: true

require 'ehbrs_ruby_utils/core_ext'
require 'ehbrs_ruby_utils/music/lyrics_book/resource'

module EhbrsRubyUtils
  module Music
    class LyricsBook
      class Album < ::EhbrsRubyUtils::Music::LyricsBook::Resource
        enable_simple_cache

        def book
          parent
        end

        def first_previous
          previous.if_present { |v| v.songs.last }
        end

        def valid?
          songs.any?
        end

        def header_title
          "#{songs.first.number}-#{songs.last.number} | #{artist} | #{title}"
        end

        def artist
          from_songs_tag(:artist)
        end

        def title
          from_songs_tag(:album)
        end

        private

        def songs_uncached
          ::EhbrsRubyUtils::Music::LyricsBook::Song.create_list(self, path.children)
        end

        def from_songs_tag(field)
          songs.lazy.map { |v| v.tag.send(field) }.find(&:present?)
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.44.3 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.44.2 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.44.1 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.44.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.41.1 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.41.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.40.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.39.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.38.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.37.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.36.1 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.36.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.35.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.33.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.32.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.31.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.30.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/music/lyrics_book/album.rb