Class: SistemKebut::XML::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/xml/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(r = nil) ⇒ Builder

Returns a new instance of Builder.



190
191
192
193
194
195
196
197
198
# File 'lib/xml/builder.rb', line 190

def initialize(r=nil)
  @root = r
  @kini = nil
  if block_given?
    yield(self)
  else
    raise BuilderBlock.new 
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(nama, *args, &block) ⇒ Object



223
224
225
# File 'lib/xml/builder.rb', line 223

def method_missing(nama, *args, &block)
  inner_devel(nama, *args, &block)
end

Instance Method Details

#build(tujuan = nil) ⇒ Object



213
214
215
216
217
218
219
220
221
# File 'lib/xml/builder.rb', line 213

def build(tujuan=nil)
  hasil = inner_build.doc.root
  w_acme(hasil) if hasil.name == "document"
  w_acme(hasil) if hasil.name == "numbering"
  return case tujuan
  when :xml; hasil.to_xml
  else; hasil.serialize(save_with: 0)
  end
end

#catat_administrasi(id) ⇒ Object



209
210
211
# File 'lib/xml/builder.rb', line 209

def catat_administrasi(id)
  return LapisAdministrasi.new(id, self)
end

#raw(elm) ⇒ Object



204
205
206
207
# File 'lib/xml/builder.rb', line 204

def raw(elm)
  return nil unless elm.is_a?(Element)
  elm.raw_serialize(@kini)
end

#root_elementObject



200
201
202
# File 'lib/xml/builder.rb', line 200

def root_element
  return @root
end