Class: Cheri::Xml::TextElem

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

Direct Known Subclasses

EscElem

Constant Summary

Constants included from XmlBuilder

XmlBuilder::TCE

Instance Method Summary collapse

Methods included from XmlBuilder

#empty_io, #empty_s, #esc

Constructor Details

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

Returns a new instance of TextElem.



117
118
119
120
# File 'lib/cheri/builder/xml/element.rb', line 117

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

Instance Method Details

#modObject



127
128
129
# File 'lib/cheri/builder/xml/element.rb', line 127

def mod
  Cheri::Xml  
end

#to_io(ios) ⇒ Object

Appends content to ios. Returns the result.



146
147
148
149
150
151
152
153
154
155
# File 'lib/cheri/builder/xml/element.rb', line 146

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.



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/cheri/builder/xml/element.rb', line 133

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