Class: Ethon::Easies::Params
- Inherits:
-
Object
- Object
- Ethon::Easies::Params
- Includes:
- Util
- Defined in:
- lib/ethon/easies/params.rb
Overview
This class represents http request parameters.
Instance Attribute Summary collapse
-
#escape ⇒ Object
Returns the value of attribute escape.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Return wether there are elements in the params or not.
-
#initialize(params) ⇒ Params
constructor
Create a new Params.
-
#query_pairs ⇒ Array
Return the query pairs.
-
#to_s ⇒ String
Return the string representation of params.
Methods included from Util
#build_query_pairs, escape_zero_byte, #file_info
Constructor Details
#initialize(params) ⇒ Params
Create a new Params.
19 20 21 |
# File 'lib/ethon/easies/params.rb', line 19 def initialize(params) @params = params || {} end |
Instance Attribute Details
#escape ⇒ Object
Returns the value of attribute escape.
9 10 11 |
# File 'lib/ethon/easies/params.rb', line 9 def escape @escape end |
Instance Method Details
#empty? ⇒ Boolean
Return wether there are elements in the params or not.
49 50 51 |
# File 'lib/ethon/easies/params.rb', line 49 def empty? @params.empty? end |
#query_pairs ⇒ Array
Return the query pairs.
39 40 41 |
# File 'lib/ethon/easies/params.rb', line 39 def query_pairs @query_pairs ||= build_query_pairs(@params) end |
#to_s ⇒ String
Return the string representation of params.
29 30 31 |
# File 'lib/ethon/easies/params.rb', line 29 def to_s query_pairs.map{|pair| pair.map{|e| escape ? CGI::escape(e.to_s) : e }.join("=")}.join('&') end |