Module: Zon
- Defined in:
- lib/zon.rb,
lib/zon/zig.rb,
lib/zon/hasher.rb,
lib/zon/parser.rb,
lib/zon/version.rb,
lib/zon/serializer.rb,
sig/zon.rbs
Overview
Zig Object Notation (ZON) de-/serializer.
Defined Under Namespace
Modules: Serializer, Zig Classes: Error, Parser
Constant Summary collapse
- VERSION =
"0.3.1"
Class Method Summary collapse
-
.parse(input) ⇒ Object
Parse ZON data, represented as String or IO/File, into a Ruby object.
-
.serialize(obj, options = {}) ⇒ Object
Serialize a Ruby object into a ZON string.
Class Method Details
.parse(input) ⇒ Object
Parse ZON data, represented as String or IO/File, into a Ruby object.
An ArgumentError is raised if input is neither a String nor a IO object.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zon.rb', line 21 def self.parse(input) data = nil if input.is_a? String data = input elsif input.is_a? IO data = input.read else raise ArgumentError, "Input must be a String or a File/IO object" end tokens = Zon::Lexer.parse data parser = Zon::Parser.new tokens parser.parse end |
.serialize(obj, options = {}) ⇒ Object
Serialize a Ruby object into a ZON string.
Available options:
- { :indent_level =>
} - Define the indentation level for each block - { :ibase =>
} - Specify the base (binary: 2, octal: 8, decimal: 10, hex: 16)
43 44 45 |
# File 'lib/zon.rb', line 43 def self.serialize(obj, = {}) Zon::Serializer::serialize_object(obj, ) end |