Class: Google4R::Checkout::Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/google4r/checkout/shared.rb

Overview

This is a base class for defining the unit of weight and dimension

Direct Known Subclasses

Dimension, Weight

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUnit

Returns a new instance of Unit.



1108
1109
1110
# File 'lib/google4r/checkout/shared.rb', line 1108

def initialize
  raise "Google::Checkout::Unit is an abstract class!"
end

Instance Attribute Details

#unitObject

This specifies the unit of measurement that corresponds to a shipping package’s length, width or height. The only valid value for this attribute is IN.



1102
1103
1104
# File 'lib/google4r/checkout/shared.rb', line 1102

def unit
  @unit
end

#valueObject

This specifies the numeric value of a unit of measurement corresponding to an item or a shipping package. (float)



1106
1107
1108
# File 'lib/google4r/checkout/shared.rb', line 1106

def value
  @value
end

Class Method Details

.create_from_element(element) ⇒ Object

Creates a new Unit from the given REXML::Element instance.



1113
1114
1115
1116
# File 'lib/google4r/checkout/shared.rb', line 1113

def self.create_from_element(element)
  result = self.new(BigDecimal.new(element.attributes['value'].to_s)) 
  return result
end