Class: Jammed::Base
- Inherits:
-
Object
- Object
- Jammed::Base
- Defined in:
- lib/jammed/base.rb
Overview
A base class for interacting with the API
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Stores the API key to be used for all method calls on the Jammed::Base object.
-
#https ⇒ Object
readonly
Stores the API key to be used for all method calls on the Jammed::Base object.
Instance Method Summary collapse
-
#followers(username, opts = {}) ⇒ Object
Calls Jammed::Followers.
-
#following(username, opts = {}) ⇒ Object
Calls Jammed::Following.
-
#initialize(api_key, opts = {}) ⇒ Base
constructor
Sets the API key + any options.
-
#jams(username, opts = {}) ⇒ Object
Calls Jammed::Jams.
-
#likes(username, opts = {}) ⇒ Object
Calls Jammed::Likes.likes.
-
#popular_jams ⇒ Object
Calls Jammed::PopularJams.popular_jams.
-
#profile(username) ⇒ Object
Calls Jammed::Person.profile.
-
#random ⇒ Object
Calls Jammed::RandomJam.jam.
-
#search_artist(artist) ⇒ Object
Calls Jammed::PeopleSearch.search_artist.
-
#search_name(name) ⇒ Object
Calls Jammed::PeopleSearch.search_name.
-
#search_track(artist, track) ⇒ Object
Calls Jammed::PeopleSearch.search_track.
-
#suggested_people ⇒ Object
Calls Jammed::SuggestedPeople.people.
-
#user(username) ⇒ Object
Calls Jammed::User.new and creates a new User object for interacting with user specific data.
Constructor Details
#initialize(api_key, opts = {}) ⇒ Base
Sets the API key + any options
9 10 11 12 |
# File 'lib/jammed/base.rb', line 9 def initialize(api_key, opts={}) @api_key = api_key @https = opts[:https] ? opts[:https] : false end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Stores the API key to be used for all method calls on the Jammed::Base object
6 7 8 |
# File 'lib/jammed/base.rb', line 6 def api_key @api_key end |
#https ⇒ Object (readonly)
Stores the API key to be used for all method calls on the Jammed::Base object
6 7 8 |
# File 'lib/jammed/base.rb', line 6 def https @https end |
Instance Method Details
#followers(username, opts = {}) ⇒ Object
Calls Jammed::Followers
Attributes
-
username- Username of user whose followers you want to retrieve -
opts- Options for ordering Followers data
Options
-
:order- A symbol determining how the data is orderd like :date, :affinity, or :alpha
Examples
jammed = Jammed.new('08972935872035')
jammed.followers('IFTFOM', :order => :date)
29 30 31 32 |
# File 'lib/jammed/base.rb', line 29 def followers(username, opts={}) opts = opts.merge({:https => @https}) Followers.followers(username, @api_key, opts) end |
#following(username, opts = {}) ⇒ Object
Calls Jammed::Following
Attributes
-
username- Username of user whose followings you want to retrieve -
opts- Options for ordering Following data
Options
-
:order- A symbol determining how the data is orderd like :date, :affinity, or :alpha
Examples
jammed = Jammed.new('08972935872035')
jammed.following('IFTFOM', :order => :date)
49 50 51 52 |
# File 'lib/jammed/base.rb', line 49 def following(username, opts={}) opts = opts.merge({:https => @https}) Following.following(username, @api_key, opts) end |
#jams(username, opts = {}) ⇒ Object
Calls Jammed::Jams
Attributes
-
username- Username of user whose jams you want to retrieve -
opts- Options for which jams to retrieve
Options
-
:show- A symbol determining which data is shown (:past | :current)
Examples
jammed = Jammed.new('08972935872035')
jammed.jams('IFTFOM', :show => :current)
69 70 71 72 |
# File 'lib/jammed/base.rb', line 69 def jams(username, opts={}) opts = opts.merge({:https => @https}) Jams.jams(username, @api_key, opts) end |
#likes(username, opts = {}) ⇒ Object
Calls Jammed::Likes.likes
Attributes
-
username- Username of user whose likes you want to retrieve -
opts- Options for which likes to retrieve
Options
-
:show- A symbol determining which data is shown (:past | :current)
Examples
jammed = Jammed.new('08972935872035')
jammed.likes('IFTFOM', :show => :current)
89 90 91 92 |
# File 'lib/jammed/base.rb', line 89 def likes(username, opts={}) opts = opts.merge({:https => @https}) Likes.likes(username, @api_key, opts) end |
#popular_jams ⇒ Object
Calls Jammed::PopularJams.popular_jams
Examples
jammed = Jammed.new('08972935872035')
jammed.popular_jams
100 101 102 |
# File 'lib/jammed/base.rb', line 100 def popular_jams PopularJams.popular_jams(@api_key, @https) end |
#profile(username) ⇒ Object
Calls Jammed::Person.profile
Attributes
-
username- Username of user profile want to retrieve
Examples
jammed = Jammed.new('08972935872035')
jammed.profile('IFTFOM')
114 115 116 |
# File 'lib/jammed/base.rb', line 114 def profile(username) Person.profile(username, @api_key, @https) end |
#random ⇒ Object
Calls Jammed::RandomJam.jam
Examples
jammed = Jammed.new('08972935872035')
jammed.random
124 125 126 |
# File 'lib/jammed/base.rb', line 124 def random RandomJam.jam(@api_key, @https) end |
#search_artist(artist) ⇒ Object
Calls Jammed::PeopleSearch.search_artist
Attributes
*artist - Artist you want to search by
Examples
jammed = Jammed.new('08972935872035')
jammed.search_artist('IFTFOM')
152 153 154 |
# File 'lib/jammed/base.rb', line 152 def search_artist(artist) PeopleSearch.search_artist(artist, @api_key, @https) end |
#search_name(name) ⇒ Object
Calls Jammed::PeopleSearch.search_name
Attributes
*name - Name you want to search by
Examples
jammed = Jammed.new('08972935872035')
jammed.search_name('IFTFOM')
138 139 140 |
# File 'lib/jammed/base.rb', line 138 def search_name(name) PeopleSearch.search_name(name, @api_key, @https) end |
#search_track(artist, track) ⇒ Object
Calls Jammed::PeopleSearch.search_track
Attributes
*artist - Artist you want to search by *track - Track you want to search by
Examples
jammed = Jammed.new('08972935872035')
jammed.search_track('IFTFOM')
167 168 169 |
# File 'lib/jammed/base.rb', line 167 def search_track(artist, track) PeopleSearch.search_track(artist, track, @api_key, @https) end |
#suggested_people ⇒ Object
Calls Jammed::SuggestedPeople.people
Examples
jammed = Jammed.new('08972935872035')
jammed.suggest_people
177 178 179 |
# File 'lib/jammed/base.rb', line 177 def suggested_people SuggestedPeople.people(@api_key, @https) end |
#user(username) ⇒ Object
Calls Jammed::User.new and creates a new User object for interacting with user specific data. It provides methods for interacting with user-specific data.
Attributes
-
username- Username of user you want the object oriented with
Examples
jammed = Jammed.new('08972935872035')
ift = jammed.user('IFTFOM')
ift.profile
ift.jams(:show => :past)
193 194 195 |
# File 'lib/jammed/base.rb', line 193 def user(username) User.new(username, @api_key, @https) end |