Class: GoogleCheckout::Geography::UsCountry

Inherits:
Area
  • Object
show all
Defined in:
lib/google-checkout/geography/us_country.rb

Constant Summary collapse

VALID_REGIONS =
[:continental_48, :full_50_states, :all]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region) ⇒ UsCountry

Returns a new instance of UsCountry.



9
10
11
# File 'lib/google-checkout/geography/us_country.rb', line 9

def initialize(region)
  self.region = region
end

Instance Attribute Details

#regionObject

Returns the value of attribute region.



7
8
9
# File 'lib/google-checkout/geography/us_country.rb', line 7

def region
  @region
end

Instance Method Details

#to_xmlObject



13
14
15
16
17
18
19
20
# File 'lib/google-checkout/geography/us_country.rb', line 13

def to_xml
  unless VALID_REGIONS.include?(@region.to_sym)
    raise ArgumentError,
      ":#{@region.to_s} is not a valid region. You may use :continental_48, :full_50_states or :all"
  end
  xml = Builder::XmlMarkup.new
  xml.tag!('us-country-area', 'country-area' => @region.to_s.upcase)
end