Class: Micky::Response

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

Overview

Delegates to a Net::HTTPResponse instance

Instance Method Summary collapse

Instance Method Details

#ai(*args) ⇒ Object

Support for awesome_print



34
35
36
# File 'lib/micky/response.rb', line 34

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

#data ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/micky/response.rb', line 6

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

#data_uri ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/micky/response.rb', line 16

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



29
30
31
# File 'lib/micky/response.rb', line 29

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

#to_s ⇒ Object



25
26
27
# File 'lib/micky/response.rb', line 25

def to_s
  body
end