Class: BBC::Music::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/music/artist.rb

Constant Summary collapse

CLIENT =
BBC::Client.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Artist

Returns a new instance of Artist.



13
14
15
# File 'lib/bbc/music/artist.rb', line 13

def initialize(params)
  populate_from params
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def id
  @id
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def image_url
  @image_url
end

Returns the value of attribute links.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def links
  @links
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def name
  @name
end

Returns the value of attribute related_artists.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def related_artists
  @related_artists
end

#releasesObject (readonly)

Returns the value of attribute releases.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def releases
  @releases
end

#reviewsObject (readonly)

Returns the value of attribute reviews.



7
8
9
# File 'lib/bbc/music/artist.rb', line 7

def reviews
  @reviews
end

Class Method Details

.find(id) ⇒ Object



9
10
11
# File 'lib/bbc/music/artist.rb', line 9

def self.find(id)
  new(CLIENT.artists(id))
end

Instance Method Details

#get_detailsObject



17
18
19
20
21
22
# File 'lib/bbc/music/artist.rb', line 17

def get_details
  unless @details_retreived
    populate_from CLIENT.artists(id)
    @details_retreived = true
  end
end

#to_hObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bbc/music/artist.rb', line 24

def to_h
  {
    :id => id,
    :name => name,
    :description => description,
    :releases => releases,
    :reviews => reviews,
    :links => links,
    :image_url => image_url,
    :related_artists => related_artists
  }
end

#to_json(options = {}) ⇒ Object



37
38
39
# File 'lib/bbc/music/artist.rb', line 37

def to_json(options={})
  JSON.generate(to_h)
end