Class: Bandcamp::Band

Inherits:
Base
  • Object
show all
Defined in:
lib/bandcamp.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

url

Constructor Details

#initialize(band) ⇒ Band

Returns a new instance of Band.



29
30
31
32
33
34
35
# File 'lib/bandcamp.rb', line 29

def initialize(band)      
  @name        = band['name']
  @url         = band['url']
  @band_id     = band['band_id']
  @subdomain   = band['subdomain']
  @offsite_url = band['offsite_url']
end

Instance Attribute Details

#band_idObject (readonly)

Returns the value of attribute band_id.



27
28
29
# File 'lib/bandcamp.rb', line 27

def band_id
  @band_id
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/bandcamp.rb', line 27

def name
  @name
end

#offsite_urlObject (readonly)

Returns the value of attribute offsite_url.



27
28
29
# File 'lib/bandcamp.rb', line 27

def offsite_url
  @offsite_url
end

#subdomainObject (readonly)

Returns the value of attribute subdomain.



27
28
29
# File 'lib/bandcamp.rb', line 27

def subdomain
  @subdomain
end

#urlObject (readonly)

Returns the value of attribute url.



27
28
29
# File 'lib/bandcamp.rb', line 27

def url
  @url
end

Class Method Details

.find(name) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/bandcamp.rb', line 43

def find(name)
  response = get("/band/3/search", :query => { :key => Bandcamp::Base.api_key, :name => name })
  if response && response['results']
    response['results'].map { |band| new(band) } 
  else
    response
  end
end

.load(*band_ids) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/bandcamp.rb', line 52

def load(*band_ids)
  response = get("/band/3/info", :query => { :key => Bandcamp::Base.api_key, :band_id => band_ids.join(",") })
  if band_ids.length > 1
    band_ids.map { |band_id|
      new(response[band_id.to_s])
    }
  else
    new(response) if response
  end
end

Instance Method Details

#discographyObject



37
38
39
40
# File 'lib/bandcamp.rb', line 37

def discography
  response = self.class.get("/band/3/discography", :query => { :key => Bandcamp::Base.api_key, :band_id => band_id })
  return response['discography'] if response && response['discography'] 
end