Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/tagfinder/parser.rb
Instance Method Summary collapse
- #find_text_in_document(text) ⇒ Object
-
#initialize(url) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(url) ⇒ Parser
Returns a new instance of Parser.
4 5 6 |
# File 'lib/tagfinder/parser.rb', line 4 def initialize(url) @url = url end |
Instance Method Details
#find_text_in_document(text) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/tagfinder/parser.rb', line 8 def find_text_in_document(text) agent = Mechanize.new page = agent.get(@url) result = page.search(":contains('#{text}'):not(:has(:contains('#{text}')))") if !result.to_s.empty? return result end return nil end |