Class: Discogs::Base
- Inherits:
-
Object
- Object
- Discogs::Base
- Defined in:
- lib/base.rb
Constant Summary collapse
- DISCOGS_BASE_URL =
'http://www.discogs.com'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#request_string ⇒ Object
Returns the value of attribute request_string.
-
#request_type ⇒ Object
Returns the value of attribute request_type.
Instance Method Summary collapse
-
#fetched ⇒ Object
:nodoc:.
-
#initialize(request_string = nil, request_type = :artist) ⇒ Base
constructor
A new instance of Base.
-
#parsed ⇒ Object
Hpricot parsed XML.
Constructor Details
#initialize(request_string = nil, request_type = :artist) ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 |
# File 'lib/base.rb', line 14 def initialize(request_string = nil, request_type = :artist) @api_key = load_api_key @request_string = request_string @request_type = request_type.to_s end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/base.rb', line 10 def api_key @api_key end |
#request_string ⇒ Object
Returns the value of attribute request_string.
10 11 12 |
# File 'lib/base.rb', line 10 def request_string @request_string end |
#request_type ⇒ Object
Returns the value of attribute request_type.
10 11 12 |
# File 'lib/base.rb', line 10 def request_type @request_type end |
Instance Method Details
#fetched ⇒ Object
:nodoc:
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/base.rb', line 25 def fetched #:nodoc: @fetched ||= begin begin gz = Zlib::GzipReader.new(open(request_url, 'Accept-encoding' => 'gzip, deflate')) fetched = gz.read gz.close rescue fetched = open(request_url).read end fetched end end |
#parsed ⇒ Object
Hpricot parsed XML
21 22 23 |
# File 'lib/base.rb', line 21 def parsed @parsed ||= Hpricot.XML(fetched) end |