class HtmlGen::TextEle

Attributes

args[R]
str[R]

Returns the text that this element holds.

Public Class Methods

new(args) click to toggle source
# File lib/html_gen/text_ele.rb, line 4
def initialize(args)
  @str = args[:str]
  @html = args[:html]
  @inden = args[:inden]
  @nl = args[:nl]
end

Public Instance Methods

html(args) click to toggle source

Returns the text HTML-escaped.

# File lib/html_gen/text_ele.rb, line 15
def html(args)
  str = ""
  str << @inden * level(args) if pretty?(args)
  str << html_content
  str << @nl if pretty?(args)
  str
end

Private Instance Methods

html_content() click to toggle source
# File lib/html_gen/text_ele.rb, line 37
def html_content
  if @str
    HtmlGen.escape_html(@str)
  else
    @html
  end
end
level(args) click to toggle source
# File lib/html_gen/text_ele.rb, line 29
def level(args)
  if args[:level]
    args[:level]
  else
    0
  end
end
pretty?(args) click to toggle source
# File lib/html_gen/text_ele.rb, line 25
def pretty?(args)
  !args.key?(:pretty) || args[:pretty]
end