module Ox::Builder::DSL

Public Instance Methods

cdata!(text) click to toggle source
# File lib/ox/builder/dsl.rb, line 14
def cdata!(text)
  node << Ox::CData.new(text)
end
comment!(text) click to toggle source
# File lib/ox/builder/dsl.rb, line 18
def comment!(text)
  node << Ox::Comment.new(text)
end
doctype!(type) click to toggle source
# File lib/ox/builder/dsl.rb, line 22
def doctype!(type)
  node << Ox::DocType.new(type)
end
instruct!(*args) click to toggle source
# File lib/ox/builder/dsl.rb, line 4
def instruct!(*args)
  attributes = args.last.is_a?(Hash) ? args.pop : { version: '1.0', encoding: 'UTF-8' }
  name = args.first || :xml

  with_dsl(Ox::Instruct.new(name)) do |instruct|
    instruct.add_attributes(attributes)
    node << instruct.node
  end
end
tag!(name, *args, &block) click to toggle source
# File lib/ox/builder/dsl.rb, line 26
def tag!(name, *args, &block)
  builder = Builder.build(Ox::Element.new(name), &block).tap do |tag|
    attributes = args.last.is_a?(Hash) ? args.pop : {}

    tag.add_attributes(attributes)

    args.each do |text|
      text = text.is_a?(Ox::Node) ? text : text.to_s
      tag.node << text
    end
  end

  node << builder.node
end