Fixes
This commit is contained in:
parent
f0f1730fc3
commit
08a5673933
|
@ -28,14 +28,14 @@ Robbie.setup(api_key: "your api key", api_secret: "your api secret")
|
||||||
|
|
||||||
foo = Robbie::Artist.find_by_name("foo fighters")
|
foo = Robbie::Artist.find_by_name("foo fighters")
|
||||||
# <Robbie::Artist:0x007fb9cbd7c120
|
# <Robbie::Artist:0x007fb9cbd7c120
|
||||||
# @id="MA0000002613",
|
# @id="MN0000184043",
|
||||||
# @name="Foo Fighters",
|
# @name="Foo Fighters",
|
||||||
# @is_group=true,
|
# @is_group=true,
|
||||||
# @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]
|
# @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]
|
||||||
# >
|
# >
|
||||||
|
|
||||||
# ...or directly by id
|
# ...or directly by id
|
||||||
foo = Robbie::Artist.find("MA0000002613")
|
foo = Robbie::Artist.find("MN0000184043")
|
||||||
|
|
||||||
foo.albums.last
|
foo.albums.last
|
||||||
# <Robbie::Album:0x007fb9cc16b790 @id="MW0002115022", @title="Wasting Light">
|
# <Robbie::Album:0x007fb9cc16b790 @id="MW0002115022", @title="Wasting Light">
|
||||||
|
|
|
@ -18,6 +18,7 @@ require "robbie/autocomplete"
|
||||||
|
|
||||||
module Robbie
|
module Robbie
|
||||||
@@cache_enabled = false
|
@@cache_enabled = false
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def setup(params)
|
def setup(params)
|
||||||
const_set(:API_KEY, params[:api_key])
|
const_set(:API_KEY, params[:api_key])
|
||||||
|
|
|
@ -6,6 +6,10 @@ module Robbie
|
||||||
def search(q)
|
def search(q)
|
||||||
Parsers::Search.search(q).keep_if{ |item| item.instance_of?(Robbie::Album) }
|
Parsers::Search.search(q).keep_if{ |item| item.instance_of?(Robbie::Album) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find(id)
|
||||||
|
Parsers::Album.find(id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def tracks
|
def tracks
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
module Robbie
|
module Robbie
|
||||||
class BaseModel
|
class BaseModel
|
||||||
def initialize(values)
|
def initialize(values)
|
||||||
values.each do |key, val|
|
values.each{ |key, val| send(:"#{key}=", val) }
|
||||||
send(:"#{key}=", val)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
module Robbie
|
module Robbie
|
||||||
class Track < BaseModel
|
class Track < BaseModel
|
||||||
attr_accessor :id, :disc_id, :position, :artists, :title, :duration
|
attr_accessor :id, :disc_id, :position, :artists, :title, :duration
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def find(id)
|
||||||
|
Parsers::Track.find(id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue