class Seahorse::Client::Xml::Builder::XmlDoc
def attributes(attr)
def attributes(attr) if attr.empty? '' else ' ' + attr.map do |key, value| "#{key}=\"#{escape(value).gsub('"', '"')}\"" end.join(' ') end end
def close_el(name)
def close_el(name) "</#{name}>#{@end_of_line}" end
def empty_element(name, attrs)
def empty_element(name, attrs) "#{@pad}<#{name}#{attributes(attrs)}/>#{@end_of_line}" end
def escape(string)
def escape(string) string.to_s end
def increase_pad(&block)
def increase_pad(&block) pre_increase = @pad @pad = @pad + @indent yield @pad = pre_increase end
def initialize(options = {})
(**options)
-
:indent
(String
) -- -
:pad
(String
) -- -
:target
(#<<
) --
def initialize(options = {}) @target = options[:target] || '' @indent = options[:indent] || '' @pad = options[:pad] || '' @end_of_line = @indent == '' ? '' : "\n" end
def inline_element(name, value, attrs)
def inline_element(name, value, attrs) "#{open_el(name, attrs)}#{escape(value)}#{close_el(name)}" end
def node(name, *args, &block)
-
(void)
-
Overloads:
-
node(name, attributes = {}, &block)
-
node(name, value, attributes = {})
-
node(name, attributes = {})
def node(name, *args, &block) attrs = args.last.is_a?(Hash) ? args.pop : {} if block_given? @target << open_el(name, attrs) @target << @end_of_line increase_pad { yield } @target << @pad @target << close_el(name) elsif args.empty? @target << empty_element(name, attrs) else @target << inline_element(name, args.first, attrs) end end
def open_el(name, attrs)
def open_el(name, attrs) "#{@pad}<#{name}#{attributes(attrs)}>" end