Class: Watobo::Response

Inherits:
Array
  • Object
show all
Defined in:
lib/watobo/core/response.rb

Overview

:nodoc: all

Constant Summary

Constants included from Diff::LCS

Diff::LCS::BalancedCallbacks, Diff::LCS::PATCH_MAP, Diff::LCS::SequenceCallbacks, Diff::LCS::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Diff::LCS

LCS, __diff_direction, __inverse_vector, __lcs, __normalize_patchset, __position_hash, __replace_next_larger, diff, #diff, #lcs, patch, #patch, #patch!, patch!, sdiff, #sdiff, traverse_balanced, #traverse_balanced, traverse_sequences, #traverse_sequences, #unpatch, #unpatch!, unpatch!

Constructor Details

#initialize(r) ⇒ Response

Returns a new instance of Response.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/watobo/core/response.rb', line 51

def initialize(r)
  if r.respond_to? :concat
    #puts "Create REQUEST from ARRAY"
   self.concat r
  elsif r.is_a? String
   raise ArgumentError, "Need Array"
  end
  self.extend Watobo::Mixin::Parser::Url
  self.extend Watobo::Mixin::Parser::Web10
  self.extend Watobo::Mixin::Shaper::Web10
  self.extend Watobo::Mixin::Shaper::HttpResponse
  
  if content_type =~ /(html|text)/
    self.extend Watobo::Parser::HTML
  end
  
end

Class Method Details

.create(response) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
# File 'lib/watobo/core/response.rb', line 22

def self.create( response )
  raise ArgumentError, "Array Expected." unless response.is_a? Array
  response.extend Watobo::Mixin::Parser::Url
  response.extend Watobo::Mixin::Parser::Web10
  response.extend Watobo::Mixin::Shaper::Web10
  response.extend Watobo::Mixin::Shaper::HttpResponse
end

.is_html?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/watobo/core/response.rb', line 13

def self.is_html?
  
end

.is_json?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/watobo/core/response.rb', line 17

def self.is_json?
  
end

Instance Method Details

#copyObject



46
47
48
49
# File 'lib/watobo/core/response.rb', line 46

def copy
  c = Watobo::Utils.copyObject self
  Watobo::Request.new c
end

#dataObject



42
43
44
# File 'lib/watobo/core/response.rb', line 42

def data
  @data
end

#to_sObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/watobo/core/response.rb', line 30

def to_s
  data = self.join
  
  
  
  unless has_body?
    data << "\r\n" unless data =~ /\r\n\r\n$/
  end
  data
end