Class: HtmlGen::TextEle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ TextEle

Returns a new instance of TextEle.



4
5
6
7
8
# File 'lib/html_gen/text_ele.rb', line 4

def initialize(args)
  @str = args[:str]
  @inden = args[:inden]
  @nl = args[:nl]
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



2
3
4
# File 'lib/html_gen/text_ele.rb', line 2

def args
  @args
end

Instance Method Details

#html(args) ⇒ Object

Returns the text HTML-escaped.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/html_gen/text_ele.rb', line 16

def html(args)
  if args[:level]
    level = args[:level]
  else
    level = 0
  end

  if !args.key?(:pretty) or args[:pretty]
    pretty = true
  else
    pretty = false
  end

  str = ""
  str << @inden * level if pretty
  str << HtmlGen.escape_html(@str)
  str << @nl if pretty

  return str
end

#strObject

Returns the text that this element holds.



11
12
13
# File 'lib/html_gen/text_ele.rb', line 11

def str
  return @str
end