Sha256: 633ade2cc4dc146ff253e78158edb3f10f3a70c2841e35e75fc6fb68837dab10
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
class SymbolMatrix < Hash class Serialization def self.parse serialization result = SymbolMatrix.new if serialization.include? " " serialization.split(" ").each do |command| result = result.recursive_merge parse command end else parts = serialization.split ":" unless parts.first.include? "." begin parts[1] = Integer parts.last rescue ArgumentError => e end result.merge! parts.first => parts.last else the_key = serialization[0..serialization.index(".") -1] result[the_key] = parse serialization[serialization.index(".")+1..-1] end end result end end def initialize argument = nil if argument.is_a? String if File.exist? argument from.file argument else begin from.yaml argument rescue NoMethodError => e from.serialization argument end end else merge! argument unless argument.nil? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
symbolmatrix-1.1.0 | lib/symbolmatrix/serialization.rb |
symbolmatrix-1.0.0 | lib/symbolmatrix/serialization.rb |