Class: Fleakr::Api::ValueParameter
- Inherits:
-
Object
- Object
- Fleakr::Api::ValueParameter
- Defined in:
- lib/fleakr/api/value_parameter.rb
Overview
ValueParameter
A simple name / value parameter for use in API calls
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, include_in_signature = true) ⇒ ValueParameter
constructor
Create a new parameter with the specified name / value pair.
-
#to_form ⇒ Object
Generate the form representation of this parameter.
-
#to_query ⇒ Object
Generate the query string representation of this parameter.
Constructor Details
#initialize(name, value, include_in_signature = true) ⇒ ValueParameter
Create a new parameter with the specified name / value pair.
14 15 16 17 |
# File 'lib/fleakr/api/value_parameter.rb', line 14 def initialize(name, value, include_in_signature = true) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/fleakr/api/value_parameter.rb', line 10 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/fleakr/api/value_parameter.rb', line 10 def value @value end |
Instance Method Details
#to_form ⇒ Object
Generate the form representation of this parameter.
27 28 29 30 31 |
# File 'lib/fleakr/api/value_parameter.rb', line 27 def to_form "Content-Disposition: form-data; name=\"#{self.name}\"\r\n" + "\r\n" + "#{self.value}\r\n" end |
#to_query ⇒ Object
Generate the query string representation of this parameter.
21 22 23 |
# File 'lib/fleakr/api/value_parameter.rb', line 21 def to_query "#{self.name}=#{CGI.escape(self.value.to_s)}" end |