Class: ActsAsContentHighlightable::HtmlNodeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_content_highlightable/html_node_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ HtmlNodeParser

Returns a new instance of HtmlNodeParser.



3
4
5
6
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 3

def initialize(content)
  @content = content
  @parsed = Nokogiri::HTML.parse(@content)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



8
9
10
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 8

def content
  @content
end

#parsedObject

Returns the value of attribute parsed.



8
9
10
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 8

def parsed
  @parsed
end

Instance Method Details

#assign_unique_node_identifiers(attribute_name) ⇒ Object



10
11
12
13
14
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 10

def assign_unique_node_identifiers(attribute_name)
  @running_unique_identifiers = Array.new
  apply_unique_identifiers_to_children(@parsed, attribute_name)
  return self
end

#body_contentObject



16
17
18
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 16

def body_content
  return @parsed.css('body').inner_html
end

#body_textObject



20
21
22
# File 'lib/acts_as_content_highlightable/html_node_parser.rb', line 20

def body_text
  return @parsed.text
end