class Array

Public Instance Methods

to_toml(path = "") click to toggle source
# File lib/toml/monkey_patch.rb, line 56
def to_toml(path = "")
  unless self.map(&:class).uniq.length == 1
    raise "All array values must be the same type"
  end

  if self.first.toml_table?
    toml = ""
    self.each do |val|
      toml << "\n[[#{path}]]\n"
      toml << val.to_toml(path)
    end
    return toml
  else
    "[" + self.map {|v| v.to_toml(path) }.join(",") + "]"
  end
end