Class: StructureButcher::Storer

Inherits:
Object
  • Object
show all
Defined in:
lib/structurebutcher.rb

Instance Method Summary collapse

Instance Method Details

#save_structure(structure, filename, format) ⇒ Object



131
132
133
# File 'lib/structurebutcher.rb', line 131

def save_structure(structure, filename, format)
    File.write(filename, structure_in_format(structure, format))
end

#structure_in_format(structure, format) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/structurebutcher.rb', line 116

def structure_in_format(structure, format)
    case format
    when "json"
        return JSON.generate(structure)
    when "yaml"
        return structure.to_yaml
    when "properties"
        return JavaProperties.generate(structure)
    when "hocon"
        return JSON.generate(structure) #FIXME
    else
        throw "Unsupported format"
    end
end