Class: Pricecut::Elements::Text

Inherits:
Element
  • Object
show all
Defined in:
lib/pricecut/elements/text.rb

Instance Attribute Summary

Attributes inherited from Element

#node, #visitor

Instance Method Summary collapse

Methods inherited from Element

#append_newline, #append_output, #initialize, #yield_children

Constructor Details

This class inherits a constructor from Pricecut::Elements::Element

Instance Method Details

#output!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pricecut/elements/text.rb', line 4

def output!
  return if whitespace_only?

  output = node.text

  output.tr!("\n", " ")
  output.squeeze!(" ")

  output.lstrip! unless previous_sibling?
  output.rstrip! unless next_sibling?

  p output
end