class Slasher

Attributes

content[RW]
dom[RW]

Public Class Methods

new(html) click to toggle source
# File lib/slasher.rb, line 7
def initialize(html)
  @dom      = Slasher::DOM.new(html)
  @content  = Slasher::Content.new
end

Public Instance Methods

recursive_slash(doc) click to toggle source
# 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
      content.push_content dom.get_paragraphs_content(child)
    end

    if child.children.count > 0
      recursive_slash(child)
    else
      content.push_content(child.text) if child.text != '' && !child.text.nil?
    end
  end
end
reset(html) click to toggle source
# File lib/slasher.rb, line 28
def reset(html)
  @dom     = Slasher::DOM.new(html)
  @content = Slasher::Content.new
end
slash() click to toggle source
# File lib/slasher.rb, line 33
def slash
  dom.remove_elements
  dom.strip_elements
  recursive_slash(dom.document)
  content.get_longest_length[:content]
end