Class: Address
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#state ⇒ Object
Returns the value of attribute state.
-
#street ⇒ Object
Returns the value of attribute street.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(street, city, state, zip) ⇒ Address
constructor
A new instance of Address.
- #to_xml(wax) ⇒ Object
Constructor Details
#initialize(street, city, state, zip) ⇒ Address
Returns a new instance of Address.
4 5 6 |
# File 'lib/address.rb', line 4 def initialize(street, city, state, zip) @street, @city, @state, @zip = street, city, state, zip end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
2 3 4 |
# File 'lib/address.rb', line 2 def city @city end |
#state ⇒ Object
Returns the value of attribute state.
2 3 4 |
# File 'lib/address.rb', line 2 def state @state end |
#street ⇒ Object
Returns the value of attribute street.
2 3 4 |
# File 'lib/address.rb', line 2 def street @street end |
#zip ⇒ Object
Returns the value of attribute zip.
2 3 4 |
# File 'lib/address.rb', line 2 def zip @zip end |
Instance Method Details
#to_xml(wax) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/address.rb', line 8 def to_xml(wax) # Chaining approach #wax.start('address'). # child('street', @street). # child('city', @city). # child('state', @state). # child('zip', @zip). # end! # Non-chaining approach # Put the current object in a local variable # so it can be accessed in the block passed to the write method. address = self wax.write do start 'address' child 'street', address.street child 'city', address.city child 'state', address.state child 'zip', address.zip end! end end |