Sha256: 5c3b71362f2f0b110a97ff42b2dcef44576f9a4e4d3beadb3c7acd1b7ea25761
Contents?: true
Size: 992 Bytes
Versions: 12
Compression:
Stored size: 992 Bytes
Contents
require 'forwardable' module Junoser module Display class ConfigStore extend Forwardable OFFSET = ' ' def initialize(depth=0) @hash = {} @depth = depth end def push(str) store = self join_arg(str).split("\n").each_with_index do |element, index| store[element] ||= self.class.new(index+1) store = store[element] end end alias << push def to_s str = '' each do |k, v| if v.empty? str << OFFSET*@depth << "#{k};\n" else str << OFFSET*@depth << "#{k} {\n" str << v.to_s.chop << "\n" str << OFFSET*@depth << "}\n" end end str end def_delegators :@hash, :[], :[]=, :each, :empty? private def join_arg(str) str.gsub!(/\narg\((.*)\)$/) { " #$1" } str.gsub!(/arg\((.*)\)/) { "#$1" } str end end end end
Version data entries
12 entries across 12 versions & 1 rubygems