Module: Pacer::Core::StringRoute
- Defined in:
- lib/pacer-xml/string_route.rb
Instance Method Summary collapse
Instance Method Details
#xml ⇒ Object
17 18 19 20 21 |
# File 'lib/pacer-xml/string_route.rb', line 17 def xml map(element_type: :xml) do |s| Nokogiri::XML(s).first_element_child end end |
#xml_stream(enter = nil, leave = nil, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/pacer-xml/string_route.rb', line 4 def xml_stream(enter = nil, leave = nil, &block) enter ||= /<\?xml/ leave ||= enter enter = build_rule :enter, enter leave = build_rule :leave, leave r = reducer(element_type: :array, enter: enter, leave: leave) do |s, lines| lines << s end.route joined = r.map(element_type: :string, info: 'join', &:join).route joined = block.call joined if block joined.xml end |