Module: Xvert
- Defined in:
- lib/xvert.rb,
lib/xvert/cli.rb,
lib/xvert/cli/xml.rb,
lib/xvert/version.rb,
lib/xvert/cli/json.rb,
lib/xvert/cli/toml.rb,
lib/xvert/cli/yaml.rb
Defined Under Namespace
Classes: CLI, UnsupportedFormatError
Constant Summary
collapse
- VERSION =
"0.4.0"
Class Method Summary
collapse
Class Method Details
.convert(text, from:, to:) ⇒ Object
19
20
21
22
|
# File 'lib/xvert.rb', line 19
def convert(text, from:, to:)
object = to_object(text, format: from)
to_text(object, format: to)
end
|
.to_object(text, format:) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/xvert.rb', line 24
def to_object(text, format:)
case format
when :json then json_to_object(text)
when :toml then toml_to_object(text)
when :yaml then yaml_to_object(text)
when :xml then xml_to_object(text)
else raise UnsupportedFormatError, format
end
end
|
.to_text(object, format:) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/xvert.rb', line 34
def to_text(object, format:)
case format
when :json then object_to_json(object)
when :toml then object_to_toml(object)
when :yaml then object_to_yaml(object)
when :xml then object_to_xml(object)
else raise UnsupportedFormatError, format
end
end
|