Class: Scrobbler::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/scrobbler/base.rb

Direct Known Subclasses

Album, Artist, Chart, Search, Tag, Track, User

Constant Summary collapse

@@coder =
HTMLEntities.new

Class Method Summary collapse

Class Method Details

.api_key=(api_key) ⇒ Object



13
14
15
# File 'lib/scrobbler/base.rb', line 13

def Base.api_key=(api_key)
    @@api_key = api_key
end

.connectionObject



25
26
27
# File 'lib/scrobbler/base.rb', line 25

def connection
  @connection ||= REST::Connection.new(API_URL)
end

.fetch_and_parse(resource) ⇒ Object



29
30
31
# File 'lib/scrobbler/base.rb', line 29

def fetch_and_parse(resource)
  Hpricot::XML(connection.get(resource))
end

.sanitize(string) ⇒ Object

Decode HTML Entities so that we have plain strings in out code



20
21
22
# File 'lib/scrobbler/base.rb', line 20

def Base.sanitize(string)
   @@coder.decode(string)
end