Class: Rbkb::Http::HeaderParams

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

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



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rbkb/http/parameters.rb', line 78

def capture(str)
  raise "arg 0 must be a string" unless str.is_a? String
  str.split(/\s*;\s*/).each do |p|
    var, val = p.split('=', 2)
    if val =~ /^(['"])(.*)\1$/
      val = $2
    end
    self << [var.strip, val]
  end
  return self
end

#to_raw(quote_val = false) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/rbkb/http/parameters.rb', line 68

def to_raw(quote_val=false)
  ret = ([nil] + self).map do |k,v| 
    if v 
      "#{k}=#{quote_val ? "\"#{v}\"" : v}"
    else 
      "#{k}" 
    end
  end.join("; ")
end