Class: Simplepay::Support::Boolean

Inherits:
Object
  • Object
show all
Defined in:
lib/simplepay/support/boolean.rb

Overview

Acts as a delegator for Simplepay::Support::Field :class.

This class acts as a helper for sending boolean values to Amazon. In their forms, booleans are expected to be either “0” or “1”, for false or true, respectively.

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Boolean

Returns a new instance of Boolean.



13
14
15
# File 'lib/simplepay/support/boolean.rb', line 13

def initialize(value)
  @value = value
end

Instance Method Details

#to_sObject

Returns “1” if the boolean is true, “0” otherwise.



20
21
22
23
# File 'lib/simplepay/support/boolean.rb', line 20

def to_s
  return '' if @value.nil?
  @value ? Simplepay::Boolean::True : Simplepay::Boolean::False
end