Class: SearchLogger::XmlParser
- Inherits:
-
Object
- Object
- SearchLogger::XmlParser
- Defined in:
- lib/search_logger/xml_parser.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(xml_file) ⇒ XmlParser
constructor
A new instance of XmlParser.
- #parse(path = 'keywords keyword') ⇒ Object
Constructor Details
#initialize(xml_file) ⇒ XmlParser
Returns a new instance of XmlParser.
5 6 7 |
# File 'lib/search_logger/xml_parser.rb', line 5 def initialize(xml_file) @file = File.open(xml_file) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/search_logger/xml_parser.rb', line 3 def file @file end |
Instance Method Details
#parse(path = 'keywords keyword') ⇒ Object
9 10 11 12 13 |
# File 'lib/search_logger/xml_parser.rb', line 9 def parse(path = 'keywords keyword') require "nokogiri" doc = Nokogiri::XML @file doc.css(path).each_with_object([]) { |e, all| all << e.content } end |