class HashToXmlMap

Attributes

hash_content[R]

Public Class Methods

new(hash_content) click to toggle source
# File lib/vym/hash_to_xml_map.rb, line 4
def initialize(hash_content)
  @hash_content = hash_content
end

Public Instance Methods

render() click to toggle source
# File lib/vym/hash_to_xml_map.rb, line 8
def render
  map = Builder::XmlMarkup.new(indent: 2)

  map.instruct! :xml, version: "1.0", encoding: "utf-8"
  map.declare! :DOCTYPE, :vymmap
  map.vymmap(version: "2.5.0") do |builder|
    builder.mapcenter do
      if hash_content && !hash_content.empty?
        generate_branch(hash_content, builder)
      end
    end
  end
end

Private Instance Methods

generate_branch(branch, builder) click to toggle source
# File lib/vym/hash_to_xml_map.rb, line 24
def generate_branch(branch, builder)
  branch.each do |title, subbranches|
    builder.heading(title)
    subbranches.each do |subbranch|
      builder.branch do
        generate_branch(subbranch, builder)
      end
    end
  end

end