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



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def billing_and_shipping
  @billing_and_shipping
end

#cityObject

Returns the value of attribute city



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def city
  @city
end

#full_nameObject

Returns the value of attribute full_name



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def full_name
  @full_name
end

#stateObject

Returns the value of attribute state



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def state
  @state
end

#streetObject

Returns the value of attribute street



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def street
  @street
end

#street2Object

Returns the value of attribute street2



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def street2
  @street2
end

#zip_codeObject

Returns the value of attribute zip_code



25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 25

def zip_code
  @zip_code
end

Instance Method Details

#state_codeObject



39
40
41
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 39

def state_code
  STATES.invert[state]
end

#state_code=(value) ⇒ Object



43
44
45
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 43

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

#summaryObject



47
48
49
50
51
52
# File 'lib/glimmer-dsl-web/samples/hello/hello_component.rb', line 47

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