Class: Paypal::Api::Parameter
- Inherits:
-
Object
- Object
- Paypal::Api::Parameter
- Defined in:
- lib/paypal_api/support/parameter.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Parameter
constructor
A new instance of Parameter.
- #parameter_parse(val) ⇒ Object
- #parse(anything) ⇒ Object
Constructor Details
#initialize(value) ⇒ Parameter
Returns a new instance of Parameter.
9 10 11 |
# File 'lib/paypal_api/support/parameter.rb', line 9 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/paypal_api/support/parameter.rb', line 7 def value @value end |
Instance Method Details
#parameter_parse(val) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/paypal_api/support/parameter.rb', line 18 def parameter_parse(val) if @parameter.class == Class if val.class == @parameter return val else raise Paypal::InvalidParameter, "'#{val}'' is not of type #{@parameter.class}" end elsif @parameter.class == Regexp match = @parameter.match(val) if match return match[0] else raise Paypal::InvalidParameter, "'#{val}' does not match #{@parameter}" end elsif @parameter.class < Parameter return @parameter.parse(val) else raise Paypal::InvalidParameter, "#{@parameter.class} is an invalid parameter specification" end end |
#parse(anything) ⇒ Object
13 14 15 16 |
# File 'lib/paypal_api/support/parameter.rb', line 13 def parse(anything) @value = anything return @value end |