Sha256: fbadf44cf25ce0d4c0520a8a8dc0d50de397d829ddef067278d0f077800854dc

Contents?: true

Size: 1.38 KB

Versions: 15

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'ehbrs_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Music
    class LyricsBook
      class Resource
        class << self
          def create_list(parent, files)
            r = files.sort.map { |path| new(parent, path) }.select(&:valid?)
            previous = parent.first_previous
            r.map do |e|
              e.reset_cache
              e.previous = previous
              previous = e
            end
          end
        end

        enable_simple_cache
        include ::Comparable
        common_constructor :parent, :path
        attr_accessor :previous

        def filename
          path.relative_path_from(parent.path)
        end

        def <=>(other)
          path <=> other.path
        end

        def link_to_header
          "<a href=\"\##{header_id}\" id=\"#{index_id}\">#{header_title}</a>"
        end

        def index_id
          "index_#{header_id}"
        end

        def header_id
          header_title.variableize
        end

        def header_index
          parent.header_index + 1
        end

        def output_main
          ::EhbrsRubyUtils::Music::LyricsBook::Resource.erb_template('main.html.erb', binding)
        end

        def output_index
          erb_template('index.html.erb')
        end

        def type
          self.class.name.demodulize.underscore
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
ehbrs_ruby_utils-0.17.2 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.17.1 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.17.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.16.1 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.16.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.15.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.14.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.13.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.12.2 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs-tools-0.28.3 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.12.1 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs-tools-0.28.2 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs-tools-0.28.1 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs_ruby_utils-0.12.0 lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
ehbrs-tools-0.28.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb