Class: Philiprehberger::TomlKit::Serializer
- Inherits:
-
Object
- Object
- Philiprehberger::TomlKit::Serializer
- Defined in:
- lib/philiprehberger/toml_kit/serializer.rb
Overview
Converts a Ruby Hash into a TOML v1.0 formatted string.
Type mapping:
- String -> TOML basic string (with escapes)
- Integer -> TOML integer
- Float -> TOML float (handles inf, nan)
- true/false -> TOML boolean
- Time -> TOML offset or local date-time
- Date -> TOML local date
- Hash with :hour/:minute/:second -> TOML local time
- Array -> TOML array (or array of tables if all elements are Hashes)
- Hash -> TOML table
Instance Method Summary collapse
-
#serialize(hash) ⇒ String
TOML formatted string.
Instance Method Details
#serialize(hash) ⇒ String
Returns TOML formatted string.
23 24 25 26 27 |
# File 'lib/philiprehberger/toml_kit/serializer.rb', line 23 def serialize(hash) lines = [] serialize_table(hash, [], lines) lines.join("\n") << "\n" end |