Class: Fleakr::Api::ValueParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/fleakr/api/value_parameter.rb

Overview

ValueParameter

A simple name / value parameter for use in API calls

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name


10
11
12
# File 'lib/fleakr/api/value_parameter.rb', line 10

def name
  @name
end

#valueObject (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_formObject

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_queryObject

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