class Oga::XML::Text

Class containing information about a single text node. Text nodes don’t have any children, attributes and the likes; just text.

Public Class Methods

new(*args) click to toggle source
Calls superclass method Oga::XML::CharacterNode::new
# File lib/oga/xml/text.rb, line 6
def initialize(*args)
  super

  @decoded = false
end

Public Instance Methods

decode_entities?() click to toggle source

@return [TrueClass|FalseClass]

# File lib/oga/xml/text.rb, line 32
def decode_entities?
  !@decoded && !inside_literal_html?
end
inside_literal_html?() click to toggle source

@return [TrueClass|FalseClass]

# File lib/oga/xml/text.rb, line 37
def inside_literal_html?
  node = parent

  node && html? && node.literal_html_name?
end
text() click to toggle source

Returns the text as a String. Upon the first call any XML/HTML entities are decoded.

@return [String]

# File lib/oga/xml/text.rb, line 22
def text
  if decode_entities?
    @text    = EntityDecoder.try_decode(@text, html?)
    @decoded = true
  end

  @text
end
text=(value) click to toggle source

@param [String] value

# File lib/oga/xml/text.rb, line 13
def text=(value)
  @decoded = false
  @text    = value
end