Class: ActiveDocument::SearchMatch
- Inherits:
-
Object
- Object
- ActiveDocument::SearchMatch
- Includes:
- Enumerable
- Defined in:
- lib/ActiveDocument/search_match.rb
Instance Method Summary collapse
- #highlighted_match(highlight_tag = nil) ⇒ Object
-
#initialize(node) ⇒ SearchMatch
constructor
A new instance of SearchMatch.
- #path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(node) ⇒ SearchMatch
Returns a new instance of SearchMatch.
22 23 24 |
# File 'lib/ActiveDocument/search_match.rb', line 22 def initialize(node) @node = node end |
Instance Method Details
#highlighted_match(highlight_tag = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ActiveDocument/search_match.rb', line 40 def highlighted_match(highlight_tag = nil) value = @node.xpath("./node()").to_s unless highlight_tag.nil? begin value[/<span class="hit">/] = "<#{highlight_tag}>" value[/<\/span>/] = "</#{highlight_tag}>" rescue IndexError value end end return value end |
#path ⇒ Object
26 27 28 |
# File 'lib/ActiveDocument/search_match.rb', line 26 def path @node.xpath("./@path").to_s end |
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/ActiveDocument/search_match.rb', line 30 def to_s value = @node.xpath("./node()").to_s begin value[/<span class="hit">/] = "" value[/<\/span>/] = "" rescue IndexError end return value end |