Method: Wgit::Document#extract_from_html
- Defined in:
- lib/wgit/document.rb
#extract_from_html(xpath, singleton: true, text_content_only: true) {|Optionally| ... } ⇒ String, Object (protected)
Extracts a value/object from this Document's @html using the given xpath parameter.
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
# File 'lib/wgit/document.rb', line 661 def extract_from_html(xpath, singleton: true, text_content_only: true) result = nil if xpath xpath = xpath.call if xpath.respond_to?(:call) result = singleton ? at_xpath(xpath) : xpath(xpath) end if result && text_content_only result = singleton ? result.content : result.map(&:content) end result = Wgit::Utils.sanitize(result) result = yield(result, self, :document) if block_given? result end |