Class: EhbrsRubyUtils::Music::LyricsBook::Resource
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::Music::LyricsBook::Resource
- Includes:
- Comparable
- Defined in:
- lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb
Instance Attribute Summary collapse
-
#previous ⇒ Object
Returns the value of attribute previous.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #filename ⇒ Object
- #header_id ⇒ Object
- #header_index ⇒ Object
- #index_id ⇒ Object
- #link_to_header ⇒ Object
- #output_index ⇒ Object
- #output_main ⇒ Object
- #type ⇒ Object
Instance Attribute Details
#previous ⇒ Object
Returns the value of attribute previous.
24 25 26 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 24 def previous @previous end |
Class Method Details
.create_list(parent, files) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 10 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 |
Instance Method Details
#<=>(other) ⇒ Object
30 31 32 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 30 def <=>(other) path <=> other.path end |
#filename ⇒ Object
26 27 28 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 26 def filename path.relative_path_from(parent.path) end |
#header_id ⇒ Object
42 43 44 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 42 def header_id header_title.variableize end |
#header_index ⇒ Object
46 47 48 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 46 def header_index parent.header_index + 1 end |
#index_id ⇒ Object
38 39 40 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 38 def index_id "index_#{header_id}" end |
#link_to_header ⇒ Object
34 35 36 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 34 def link_to_header "<a href=\"\##{header_id}\" id=\"#{index_id}\">#{header_title}</a>" end |
#output_index ⇒ Object
54 55 56 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 54 def output_index erb_template('index.html.erb') end |
#output_main ⇒ Object
50 51 52 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 50 def output_main ::EhbrsRubyUtils::Music::LyricsBook::Resource.erb_template('main.html.erb', binding) end |
#type ⇒ Object
58 59 60 |
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 58 def type self.class.name.demodulize.underscore end |