Class: Bitly::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/providers/bitly/response.rb

Direct Known Subclasses

ShortenResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, format = :json) ⇒ Response

Returns a new instance of Response.



9
10
11
12
13
14
# File 'lib/providers/bitly/response.rb', line 9

def initialize(response, format=:json)
  @response = response
  @format = format
  @parser = parser
  parse
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/providers/bitly/response.rb', line 5

def format
  @format
end

Instance Method Details

#parseObject



7
# File 'lib/providers/bitly/response.rb', line 7

def parse; end

#parserObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/providers/bitly/response.rb', line 17

def parser
  case format 
    when :json
      return JSON
    when :xml
      return Nokogiri::XML
    else
      raise UnsupportedFormat, format
  end
end