Class: Address

Inherits:
Struct
  • Object
show all
Defined in:
lib/glimmer-dsl-web/samples/hello/hello_component.rb,
lib/glimmer-dsl-web/samples/hello/hello_data_binding.rb,
lib/glimmer-dsl-web/samples/hello/hello_component_slots.rb,
lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb,
lib/glimmer-dsl-web/samples/hello/hello_component_listeners_default_slot.rb

Constant Summary collapse

STATES =
{
  "AK"=>"Alaska", "AL"=>"Alabama", "AR"=>"Arkansas", "AS"=>"American Samoa", "AZ"=>"Arizona",
  "CA"=>"California", "CO"=>"Colorado", "CT"=>"Connecticut", "DC"=>"District of Columbia", "DE"=>"Delaware",
  "FL"=>"Florida", "GA"=>"Georgia", "GU"=>"Guam", "HI"=>"Hawaii", "IA"=>"Iowa", "ID"=>"Idaho", "IL"=>"Illinois",
  "IN"=>"Indiana", "KS"=>"Kansas", "KY"=>"Kentucky", "LA"=>"Louisiana", "MA"=>"Massachusetts", "MD"=>"Maryland",
  "ME"=>"Maine", "MI"=>"Michigan", "MN"=>"Minnesota", "MO"=>"Missouri", "MS"=>"Mississippi", "MT"=>"Montana",
  "NC"=>"North Carolina", "ND"=>"North Dakota", "NE"=>"Nebraska", "NH"=>"New Hampshire", "NJ"=>"New Jersey",
  "NM"=>"New Mexico", "NV"=>"Nevada", "NY"=>"New York", "OH"=>"Ohio", "OK"=>"Oklahoma", "OR"=>"Oregon",
  "PA"=>"Pennsylvania", "PR"=>"Puerto Rico", "RI"=>"Rhode Island", "SC"=>"South Carolina", "SD"=>"South Dakota",
  "TN"=>"Tennessee", "TX"=>"Texas", "UT"=>"Utah", "VA"=>"Virginia", "VI"=>"Virgin Islands", "VT"=>"Vermont",
  "WA"=>"Washington", "WI"=>"Wisconsin", "WV"=>"West Virginia", "WY"=>"Wyoming"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#billing_and_shippingObject

Returns the value of attribute billing_and_shipping

Returns:

  • (Object)

    the current value of billing_and_shipping



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def billing_and_shipping
  @billing_and_shipping
end

#cityObject

Returns the value of attribute city

Returns:

  • (Object)

    the current value of city



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def city
  @city
end

#full_nameObject

Returns the value of attribute full_name

Returns:

  • (Object)

    the current value of full_name



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def full_name
  @full_name
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def state
  @state
end

#streetObject

Returns the value of attribute street

Returns:

  • (Object)

    the current value of street



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def street
  @street
end

#street2Object

Returns the value of attribute street2

Returns:

  • (Object)

    the current value of street2



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def street2
  @street2
end

#zip_codeObject

Returns the value of attribute zip_code

Returns:

  • (Object)

    the current value of zip_code



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 4

def zip_code
  @zip_code
end

Instance Method Details

#state_codeObject



18
19
20
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 18

def state_code
  STATES.invert[state]
end

#state_code=(value) ⇒ Object



22
23
24
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 22

def state_code=(value)
  self.state = STATES[value]
end

#summaryObject



26
27
28
29
30
31
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 26

def summary
  string_attributes = to_h.except(:billing_and_shipping)
  summary = string_attributes.values.map(&:to_s).reject(&:empty?).join(', ')
  summary += " (Billing & Shipping)" if billing_and_shipping
  summary
end