module TOML
def self.dump(hash)
# => "title = \"wow!\"\n[awesome]\nothers = false\nyou = true\n"
TOML.dump(hash)
}
}
"others"=>false
"you"=>true,
"awesome"=> {
"title"=>"wow!",
hash = {
# => "simple = true\n"
TOML.dump(title: 'TOML dump')
Examples
hash - Ruby Hash to be dumped into *TOML*
Public: Returns a *TOML* string from a Ruby Hash.
def self.dump(hash) Dumper.new(hash).toml_str end
def self.load_file(path, options = {})
Raises Errno::ENOENT if the file cannot be found.
Raises ParseError if the content has invalid TOML.
Raises ValueOverwriteError if a key is overwritten.
Returns a Ruby hash representation of the content.
# => {group: {}}
TOML.load_file('/tmp/simple.toml', symbolize_keys: true)
# => {"group"=>{}}
TOML.load_file('/tmp/simple.toml')
Examples
:symbolize_keys - true|false (optional).
options - The Hash options used to refine the parser (default: {}):
path - TOML File path
Public: Returns a hash from a *TOML* file.
def self.load_file(path, options = {}) TOML.parse(File.read(path), options) end
def self.parse(content, options = {})
Raises ValueOverwriteError if a key is overwritten.
Returns a Ruby hash representation of the content according to TOML spec.
# => {title: "TOML parser"}
TOML.parse('title = "TOML parser"', symbolize_keys: true)
# => {group: {}}
TOML.parse('[group]', symbolize_keys: true)
# => {"title"=>"TOML parser"}
TOML.parse('title = "TOML parser"')
# => {"group"=>{}}
TOML.parse('[group]')
Examples
:symbolize_keys - true|false (optional).
options - The Hash options used to refine the parser (default: {}):
content - TOML string to be parsed.
Public: Returns a hash from *TOML* content.
def self.parse(content, options = {}) Parser.new(content, options).hash end