Class: Metallum::Album

Inherits:
Object
  • Object
show all
Defined in:
lib/metallum/album.rb

Defined Under Namespace

Classes: Track

Instance Method Summary collapse

Constructor Details

#initialize(album_page) ⇒ Album

Returns a new instance of Album.



4
5
6
# File 'lib/metallum/album.rb', line 4

def initialize(album_page) 
  @page = album_page
end

Instance Method Details

#album_typeObject



18
19
20
21
# File 'lib/metallum/album.rb', line 18

def album_type
  element = @page.search("//div[@id='album_info']//dl[1]//dd[1]")
  element.text
end

#band_nameObject



13
14
15
16
# File 'lib/metallum/album.rb', line 13

def band_name
  element = @page.search("//h2[@class='band_name']")
  element.text
end

#record_labelObject



28
29
30
31
# File 'lib/metallum/album.rb', line 28

def record_label
  element = @page.search("//div[@id='album_info']//dl[2]//dd[1]")
  element.text
end

#release_dateObject



23
24
25
26
# File 'lib/metallum/album.rb', line 23

def release_date
  element = @page.search("//div[@id='album_info']//dl[1]//dd[2]")
  element.text
end

#titleObject



8
9
10
11
# File 'lib/metallum/album.rb', line 8

def title
  element = @page.search("//h1[@class='album_name']")
  element.text
end

#track_listObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/metallum/album.rb', line 33

def track_list
  tracks = []
  elements = @page.search("//table[@class='display table_lyrics']//tbody//tr[@class='odd' or @class='even']")
  elements.each do |element|
    track = Track.new
    track.title = element.children[3].text.strip
    track.duration = element.children[5].text.strip
    tracks << track
  end
  return tracks
end