Class: Micky::Response
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Micky::Response
- Defined in:
- lib/micky/response.rb
Overview
Delegates to a Net::HTTPResponse instance
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#ai(*args) ⇒ Object
Support for ‘awesome_print`.
- #data ⇒ Object
- #data_uri ⇒ Object
-
#initialize(response, uri) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #to_s ⇒ Object
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
#uri ⇒ Object (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 |
#data ⇒ Object
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_uri ⇒ Object
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 |
#inspect ⇒ Object
36 37 38 |
# File 'lib/micky/response.rb', line 36 def inspect "#<Micky::Response #{super}>" end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/micky/response.rb', line 32 def to_s body end |