Class: Tongo::Parser
- Inherits:
-
Object
- Object
- Tongo::Parser
- Defined in:
- lib/tongo/parser.rb
Instance Attribute Summary collapse
-
#ns ⇒ Object
readonly
Returns the value of attribute ns.
Instance Method Summary collapse
- #call(src) ⇒ Object
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
11 12 13 |
# File 'lib/tongo/parser.rb', line 11 def initialize( = {}) @ns = [:ns] || 'tng' end |
Instance Attribute Details
#ns ⇒ Object (readonly)
Returns the value of attribute ns.
3 4 5 |
# File 'lib/tongo/parser.rb', line 3 def ns @ns end |
Instance Method Details
#call(src) ⇒ Object
5 6 7 8 9 |
# File 'lib/tongo/parser.rb', line 5 def call(src) src = "<root xmlns:#{@ns}=\"http://blog.codecaster.es\">#{src}</root>" doc = Nokogiri::XML::DocumentFragment.parse(src) traverse_children(doc.children) end |