Module: YamlCreator
- Defined in:
- lib/yaml_creator.rb,
lib/yaml_creator/parser.rb,
lib/yaml_creator/version.rb
Overview
yaml creator module
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- VERSION =
"0.3.2"
Class Method Summary collapse
-
.from_array(filepath, array, enclosure = "") ⇒ Object
create yaml file from array(allow nest).
-
.from_hash(filepath, hash, enclosure = "") ⇒ Object
create yaml file from hash(allow nest).
-
.from_json(filepath, json, enclosure = "") ⇒ Object
create yaml file from json.
Class Method Details
.from_array(filepath, array, enclosure = "") ⇒ Object
create yaml file from array(allow nest). array is made flatter and is made as yaml.
13 14 15 16 17 18 19 |
# File 'lib/yaml_creator.rb', line 13 def self.from_array(filepath, array, enclosure="") # create yaml array. yaml_array = YamlCreator::Parser.from_array(array, enclosure) # save file. save_file(filepath, yaml_array) end |
.from_hash(filepath, hash, enclosure = "") ⇒ Object
create yaml file from hash(allow nest).
25 26 27 28 29 30 31 |
# File 'lib/yaml_creator.rb', line 25 def self.from_hash(filepath, hash, enclosure="") # create yaml array. yaml_array = YamlCreator::Parser.from_hash(hash, enclosure) # save file. save_file(filepath, yaml_array) end |
.from_json(filepath, json, enclosure = "") ⇒ Object
create yaml file from json.
37 38 39 40 41 42 43 44 45 |
# File 'lib/yaml_creator.rb', line 37 def self.from_json(filepath, json, enclosure="") # convert to hash. hash = JSON.parse(json) # create yaml array. yaml_array = from_hash(filepath, hash, enclosure) # save file. save_file(filepath, yaml_array) end |