Class: WEBrick::HTTPUtils::FormData
- Inherits:
-
String
- Object
- String
- WEBrick::HTTPUtils::FormData
- Defined in:
- lib/webrick/httputils.rb
Constant Summary collapse
- EmptyRawHeader =
[].freeze
- EmptyHeader =
{}.freeze
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#next_data ⇒ Object
writeonly
Sets the attribute next_data.
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #[](*key) ⇒ Object
- #append_data(data) ⇒ Object
- #each_data ⇒ Object
-
#initialize(*args) ⇒ FormData
constructor
A new instance of FormData.
- #list ⇒ Object (also: #to_ary)
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ FormData
Returns a new instance of FormData.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/webrick/httputils.rb', line 218 def initialize(*args) @name = @filename = @next_data = nil if args.empty? @raw_header = [] @header = nil super("") else @raw_header = EmptyRawHeader @header = EmptyHeader super(args.shift) unless args.empty? @next_data = self.class.new(*args) end end end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
215 216 217 |
# File 'lib/webrick/httputils.rb', line 215 def filename @filename end |
#name ⇒ Object
Returns the value of attribute name.
215 216 217 |
# File 'lib/webrick/httputils.rb', line 215 def name @name end |
#next_data=(value) ⇒ Object
Sets the attribute next_data
215 216 217 |
# File 'lib/webrick/httputils.rb', line 215 def next_data=(value) @next_data = value end |
Instance Method Details
#<<(str) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/webrick/httputils.rb', line 242 def <<(str) if @header super elsif str == CRLF @header = HTTPUtils::parse_header(@raw_header) if cd = self['content-disposition'] if /\s+name="(.*?)"/ =~ cd then @name = $1 end if /\s+filename="(.*?)"/ =~ cd then @filename = $1 end end else @raw_header << str end self end |
#[](*key) ⇒ Object
234 235 236 237 238 239 240 |
# File 'lib/webrick/httputils.rb', line 234 def [](*key) begin @header[key[0].downcase].join(", ") rescue StandardError, NameError super end end |
#append_data(data) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/webrick/httputils.rb', line 257 def append_data(data) tmp = self while tmp unless tmp.next_data tmp.next_data = data break end tmp = tmp.next_data end self end |
#each_data ⇒ Object
269 270 271 272 273 274 275 276 |
# File 'lib/webrick/httputils.rb', line 269 def each_data tmp = self while tmp next_data = tmp.next_data yield(tmp) tmp = next_data end end |
#list ⇒ Object Also known as: to_ary
278 279 280 281 282 283 284 |
# File 'lib/webrick/httputils.rb', line 278 def list ret = [] each_data{|data| ret << data.to_s } ret end |
#to_s ⇒ Object
288 289 290 |
# File 'lib/webrick/httputils.rb', line 288 def to_s String.new(self) end |