Class: Cheri::Xml::XmlRoot

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

Overview

TODO: special handling for these:

Constant Summary collapse

XML =

:stopdoc:

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>".freeze

Constants included from XmlBuilder

Cheri::Xml::XmlBuilder::TCE

Instance Method Summary collapse

Methods included from XmlBuilder

#empty_io, #empty_s, #esc

Constructor Details

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

Returns a new instance of XmlRoot.



218
219
220
221
222
# File 'lib/cheri/builder/xml/element.rb', line 218

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

Instance Method Details

#depthObject



260
261
262
# File 'lib/cheri/builder/xml/element.rb', line 260

def depth
  -1  
end

#format!Object



256
257
258
# File 'lib/cheri/builder/xml/element.rb', line 256

def format!
  @fmt = true  
end

#modObject



224
225
226
# File 'lib/cheri/builder/xml/element.rb', line 224

def mod
  Cheri::Xml  
end

#objectObject



228
229
230
# File 'lib/cheri/builder/xml/element.rb', line 228

def object
  self
end

#runObject



232
233
234
235
# File 'lib/cheri/builder/xml/element.rb', line 232

def run
  @ctx.call(self,&@blk) if @blk
  self
end

#to_io(ios) ⇒ Object

Appends content to ios. Returns the result.



248
249
250
251
252
253
254
# File 'lib/cheri/builder/xml/element.rb', line 248

def to_io(ios)
  ios << ' ' * @opt[:margin] if @fmt && @opt[:margin]
  ios << XML
  ios << LF if @fmt
  cont_io(ios)
  ios
end

#to_s(str = '') ⇒ Object

Appends content to str (or new String if str is omitted). Returns the result.



238
239
240
241
242
243
244
245
# File 'lib/cheri/builder/xml/element.rb', line 238

def to_s(str='')
  return to_io(str) unless String === str
  str << ' ' * @opt[:margin] if @fmt && @opt[:margin]
  str << XML
  str << 10 if @fmt
  cont_s(str)
  str
end