Class: Trunction::Truncation

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

Instance Method Summary collapse

Constructor Details

#initialize(html, max) ⇒ Truncation

Returns a new instance of Truncation.



14
15
16
17
18
# File 'lib/trunction.rb', line 14

def initialize(html, max)
  @doc = Nokogiri::HTML::DocumentFragment.parse(html)
  @max = max
  @word_count = 0
end

Instance Method Details

#executeObject



20
21
22
23
24
25
# File 'lib/trunction.rb', line 20

def execute
  find_the_last_block
  return "" if @last_block_element.nil?
  remove_everything_after(@last_block_element)
  @doc.to_html
end