Class: EhbrsRubyUtils::Music::LyricsBook::Resource

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb

Direct Known Subclasses

Album, Song

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#previousObject

Returns the value of attribute previous.



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

def previous
  @previous
end

Class Method Details

.create_list(parent, files) ⇒ Object



10
11
12
13
14
15
16
17
# 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.previous = previous
    previous = e
  end
end

Instance Method Details

#<=>(other) ⇒ Object



29
30
31
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 29

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

#filenameObject



25
26
27
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 25

def filename
  path.relative_path_from(parent.path)
end

#header_idObject



41
42
43
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 41

def header_id
  header_title.variableize
end

#header_indexObject



45
46
47
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 45

def header_index
  parent.header_index + 1
end

#index_idObject



37
38
39
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 37

def index_id
  "index_#{header_id}"
end


33
34
35
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 33

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

#output_indexObject



53
54
55
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 53

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

#output_mainObject



49
50
51
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 49

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

#typeObject



57
58
59
# File 'lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb', line 57

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