Class: HotelBeds::XmlHandler
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- HotelBeds::XmlHandler
- Defined in:
- lib/hotel_beds/xml_handler.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#selectors ⇒ Object
Returns the value of attribute selectors.
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(object) ⇒ XmlHandler
constructor
A new instance of XmlHandler.
- #start_element(name) ⇒ Object
- #text(value) ⇒ Object
Constructor Details
#initialize(object) ⇒ XmlHandler
Returns a new instance of XmlHandler.
7 8 9 10 |
# File 'lib/hotel_beds/xml_handler.rb', line 7 def initialize(object) self.object = object self.selectors = Array.new end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
5 6 7 |
# File 'lib/hotel_beds/xml_handler.rb', line 5 def object @object end |
#selectors ⇒ Object
Returns the value of attribute selectors.
5 6 7 |
# File 'lib/hotel_beds/xml_handler.rb', line 5 def selectors @selectors end |
Instance Method Details
#attr(name, value) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hotel_beds/xml_handler.rb', line 20 def attr(name, value) object.properties.select do |property| selectors == property.selectors && name.to_sym == property.attribute end.each do |property| property.value = value end end |
#end_element(name) ⇒ Object
16 17 18 |
# File 'lib/hotel_beds/xml_handler.rb', line 16 def end_element(name) self.selectors.pop end |
#start_element(name) ⇒ Object
12 13 14 |
# File 'lib/hotel_beds/xml_handler.rb', line 12 def start_element(name) self.selectors.push(name.to_sym) end |
#text(value) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/hotel_beds/xml_handler.rb', line 28 def text(value) object.properties.select do |property| selectors == property.selectors && property.content? end.each do |property| property.value = value end end |