1
0
Fork 0
This commit is contained in:
Gregory Eremin 2012-08-26 08:36:26 +04:00
parent f0f1730fc3
commit 08a5673933
6 changed files with 16 additions and 7 deletions

View File

@ -28,14 +28,14 @@ Robbie.setup(api_key: "your api key", api_secret: "your api secret")
foo = Robbie::Artist.find_by_name("foo fighters")
# <Robbie::Artist:0x007fb9cbd7c120
# @id="MA0000002613",
# @id="MN0000184043",
# @name="Foo Fighters",
# @is_group=true,
# @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]
# >
# ...or directly by id
foo = Robbie::Artist.find("MA0000002613")
foo = Robbie::Artist.find("MN0000184043")
foo.albums.last
# <Robbie::Album:0x007fb9cc16b790 @id="MW0002115022", @title="Wasting Light">

View File

@ -18,6 +18,7 @@ require "robbie/autocomplete"
module Robbie
@@cache_enabled = false
class << self
def setup(params)
const_set(:API_KEY, params[:api_key])

View File

@ -4,7 +4,11 @@ module Robbie
class << self
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
def find(id)
Parsers::Album.find(id)
end
end

View File

@ -4,7 +4,7 @@ module Robbie
class << self
def search(q)
Parsers::Search.search(q).keep_if { |item| item.instance_of?(Robbie::Artist) }
Parsers::Search.search(q).keep_if{ |item| item.instance_of?(Robbie::Artist) }
end
def find_by_name(name)

View File

@ -1,9 +1,7 @@
module Robbie
class BaseModel
def initialize(values)
values.each do |key, val|
send(:"#{key}=", val)
end
values.each{ |key, val| send(:"#{key}=", val) }
end
end
end

View File

@ -1,5 +1,11 @@
module Robbie
class Track < BaseModel
attr_accessor :id, :disc_id, :position, :artists, :title, :duration
class << self
def find(id)
Parsers::Track.find(id)
end
end
end
end