Class: Person
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#birthdate ⇒ Object
Returns the value of attribute birthdate.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, birthdate, address) ⇒ Person
constructor
A new instance of Person.
- #to_xml(wax) ⇒ Object
Constructor Details
#initialize(name, birthdate, address) ⇒ Person
Returns a new instance of Person.
4 5 6 |
# File 'lib/person.rb', line 4 def initialize(name, birthdate, address) @name, @birthdate, @address = name, birthdate, address end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/person.rb', line 2 def address @address end |
#birthdate ⇒ Object
Returns the value of attribute birthdate.
2 3 4 |
# File 'lib/person.rb', line 2 def birthdate @birthdate end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/person.rb', line 2 def name @name 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 |
# File 'lib/person.rb', line 8 def to_xml(wax) # Chaining approach #wax.start('person').attr('birthdate', @birthdate).child('name', @name) #@address.to_xml(wax) #wax.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. person = self wax.write do start 'person' attr 'birthdate', person.birthdate child 'name', person.name person.address.to_xml(self) # self is the WAX object here end! end end |