Class: Micky::Response

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/micky/response.rb

Overview

Delegates to a Net::HTTPResponse instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, uri) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/micky/response.rb', line 8

def initialize(response, uri)
  super(response)
  @uri = uri
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/micky/response.rb', line 6

def uri
  @uri
end

Instance Method Details

#ai(*args) ⇒ Object

Support for ‘awesome_print`



41
42
43
# File 'lib/micky/response.rb', line 41

def ai(*args)
  "#<Micky::Response #{super}>"
end

#dataObject



13
14
15
16
17
18
19
20
21
# File 'lib/micky/response.rb', line 13

def data
  @data ||= begin
    if body and parser = Micky.parsers[content_type]
      parser.call(body)
    else
      body
    end
  end
end

#data_uriObject



23
24
25
26
27
28
29
30
# File 'lib/micky/response.rb', line 23

def data_uri
  @data_uri ||= begin
    if body
      require 'base64' unless defined? Base64
      "data:#{content_type};base64,#{Base64.encode64(body)}"
    end
  end
end

#inspectObject



36
37
38
# File 'lib/micky/response.rb', line 36

def inspect
  "#<Micky::Response #{super}>"
end

#to_sObject



32
33
34
# File 'lib/micky/response.rb', line 32

def to_s
  body
end