Class: Cheri::Html::TextElem

Inherits:
Object
  • Object
show all
Includes:
Builder::MarkupLikeBuilder, HtmlBuilder
Defined in:
lib/cheri/builder/html/element.rb

Direct Known Subclasses

EscElem

Instance Method Summary collapse

Methods included from HtmlBuilder

#esc

Constructor Details

#initialize(ctx, *r, &k) ⇒ TextElem

Returns a new instance of TextElem.



109
110
111
112
# File 'lib/cheri/builder/html/element.rb', line 109

def initialize(ctx,*r,&k)
  @opt = ctx[:html_opts] || {}
  super
end

Instance Method Details

#modObject



119
120
121
# File 'lib/cheri/builder/html/element.rb', line 119

def mod
  Cheri::Html  
end

#to_io(ios) ⇒ Object

Appends content to ios. Returns the result.



138
139
140
141
142
143
144
145
146
147
# File 'lib/cheri/builder/html/element.rb', line 138

def to_io(ios)
  @cont.each do |c|
    if String === c
      ios << esc(c)
    else
      ios << esc(c.to_s)
    end
  end if @cont
  ios
end

#to_s(str = '') ⇒ Object

Appends content to str, or to an empty string if str is omitted. Returns the result.



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/cheri/builder/html/element.rb', line 125

def to_s(str='')
  return to_io(str) unless String === str
  @cont.each do |c|
    if String === c
      esc(c,str)
    else
      esc(c.to_s,str)
    end
  end if @cont
  str
end