Class: Ox::Mapper::Parser
- Inherits:
-
Object
- Object
- Ox::Mapper::Parser
- Defined in:
- lib/ox/mapper/parser.rb
Overview
Instance Method Summary collapse
- #collect_attribute(map) ⇒ Object (also: #on_attribute) deprecated Deprecated.
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#on(*elements) {|element| ... } ⇒ Object
(also: #on_element)
Define a callbacks to be called when
elements
processed. -
#parse(io, options = {}) ⇒ Object
Parse given
io
object.
Constructor Details
Instance Method Details
#collect_attribute(map) ⇒ Object Also known as: on_attribute
Deprecated.
Set attribute callback
55 56 57 58 59 60 61 62 |
# File 'lib/ox/mapper/parser.rb', line 55 def collect_attribute(map) warn 'Ox::Mapper::Parser#on_attribute method is deprecated and shall be removed in future versions. '\ 'Please use #on(element_name, :attributes => [...]) notation.' map.each_pair do |k, attributes| Array(attributes).flatten.each { |attr| @handler.collect_attribute(k, attr) } end end |
#on(*elements) {|element| ... } ⇒ Object Also known as: on_element
Define a callbacks to be called when elements
processed
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ox/mapper/parser.rb', line 34 def on(*elements, &block) = (Hash === elements.last) ? elements.pop : {} attributes = Array([:attributes]).flatten elements.each do |e| @handler.setup_element_callback(e, block) attributes.each { |attr| @handler.collect_attribute(e, attr) } end end |
#parse(io, options = {}) ⇒ Object
Parse given io
object
20 21 22 |
# File 'lib/ox/mapper/parser.rb', line 20 def parse(io, = {}) Ox.sax_parse(@handler, io, ) end |