Class: Metallum::Band

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

Instance Method Summary collapse

Constructor Details

#initialize(band_page, discography_page) ⇒ Band

Returns a new instance of Band.



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

def initialize(band_page, discography_page)
  @page = band_page
  @discography = discography_page
end

Instance Method Details

#album_urlsObject



59
60
61
# File 'lib/metallum/band.rb', line 59

def album_urls
  elements = @discography.search("//tbody//tr//td[1]/a").map { |el| el.attribute("href").text }
end

#countryObject



14
15
16
17
# File 'lib/metallum/band.rb', line 14

def country
  element = @page.search("//div[@id='band_info']//dl//dd[1]//a")
  element.children[0].text
end

#genreObject



34
35
36
37
# File 'lib/metallum/band.rb', line 34

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

#locationObject



19
20
21
22
# File 'lib/metallum/band.rb', line 19

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

#logo_urlObject



54
55
56
57
# File 'lib/metallum/band.rb', line 54

def logo_url
  element = @page.search("//a[@id='logo']//img")
  element.attribute("src").text
end

#lyrical_themesObject



39
40
41
42
# File 'lib/metallum/band.rb', line 39

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

#nameObject



9
10
11
12
# File 'lib/metallum/band.rb', line 9

def name
  element = @page.search("h1[@class='band_name']")
  element.text.strip
end

#photo_urlObject



49
50
51
52
# File 'lib/metallum/band.rb', line 49

def photo_url
  element = @page.search("//a[@id='photo']//img")
  element.attribute("src").text
end

#record_labelObject



44
45
46
47
# File 'lib/metallum/band.rb', line 44

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

#statusObject



24
25
26
27
# File 'lib/metallum/band.rb', line 24

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

#year_formedObject



29
30
31
32
# File 'lib/metallum/band.rb', line 29

def year_formed
  element = @page.search("//div[@id='band_info']//dl//dd[4]")
  element.text
end