Class: Rbkb::Http::TextPlainFormParams

Inherits:
Parameters
  • Object
show all
Defined in:
lib/rbkb/http/parameters.rb

Overview

The TextPlainParams class is for Parameters values in the form of ‘text/plain’ post data. These are usually simple key=value pairs separated by a CR?LF.

XXX Note, safari seems to think these should be urlencoded, and not newline separated. joy!

Instance Method Summary collapse

Methods inherited from Parameters

#delete_param, #get_all, #get_all_values_for, #get_param, #get_value_for, #initialize, parse, #set_all_for, #set_param

Methods included from CommonInterface

#_common_init, #opts, #opts=

Constructor Details

This class inherits a constructor from Rbkb::Http::Parameters

Instance Method Details

#capture(str) ⇒ Object



142
143
144
145
146
147
148
149
# File 'lib/rbkb/http/parameters.rb', line 142

def capture(str)
  raise "arg 0 must be a string" unless str.is_a? String
  str.split(/\r?\n/).each do |p| 
    var,val = p.split('=',2)
    self << [var,val]
  end
  return self
end

#to_rawObject



132
133
134
135
136
137
138
139
140
# File 'lib/rbkb/http/parameters.rb', line 132

def to_raw
  self.map do |k,v| 
    if v
      "#{k}=#{v.urlenc}" 
    else 
      "#{k}"
    end
  end.join('\r\n')
end