Class: Trunction::Truncation
- Inherits:
-
Object
- Object
- Trunction::Truncation
- Defined in:
- lib/trunction.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(html, max) ⇒ Truncation
constructor
A new instance of Truncation.
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
#execute ⇒ Object
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 |