Class: Slasher
- Inherits:
-
Object
- Object
- Slasher
- Defined in:
- lib/slasher.rb,
lib/slasher/dom.rb,
lib/slasher/content.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#dom ⇒ Object
Returns the value of attribute dom.
Instance Method Summary collapse
-
#initialize(html) ⇒ Slasher
constructor
A new instance of Slasher.
- #recursive_slash(doc) ⇒ Object
- #slash ⇒ Object
Constructor Details
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/slasher.rb', line 5 def content @content end |
#dom ⇒ Object
Returns the value of attribute dom.
5 6 7 |
# File 'lib/slasher.rb', line 5 def dom @dom end |
Instance Method Details
#recursive_slash(doc) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/slasher.rb', line 12 def recursive_slash(doc) content.push_content(dom.get_texts(doc)) doc.children.each do |child| if child.send(:>, "p").count > 0 p_content = dom.get_paragraphs_content(child) content.push_content(p_content) end if child.children.count > 0 recursive_slash(child) else if child.text != '' && !child.text.nil? content.push_content(child.text) end end end end |
#slash ⇒ Object
31 32 33 34 35 36 |
# File 'lib/slasher.rb', line 31 def slash dom.remove_elements dom.strip_elements recursive_slash(dom.document) content.get_longest_length[:content] end |