Class: Metallum::Album
- Inherits:
-
Object
- Object
- Metallum::Album
- Defined in:
- lib/metallum/album.rb
Defined Under Namespace
Classes: Track
Instance Method Summary collapse
- #album_type ⇒ Object
- #band_name ⇒ Object
-
#initialize(album_page) ⇒ Album
constructor
A new instance of Album.
- #record_label ⇒ Object
- #release_date ⇒ Object
- #title ⇒ Object
- #track_list ⇒ Object
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_type ⇒ Object
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_name ⇒ Object
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_label ⇒ Object
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_date ⇒ Object
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 |
#title ⇒ Object
8 9 10 11 |
# File 'lib/metallum/album.rb', line 8 def title element = @page.search("//h1[@class='album_name']") element.text end |
#track_list ⇒ Object
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 |