Sha256: febe69db665d4e458722bde2e617fc1d4a2a3c2b8c1cba301241f63110ee170b

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

module Walky
  module Parser
    def self.parse(hash, path)
      paths = path.split(" ")
      return_hash = hash
      paths.each do |pathy|
        if pathy =~ /^:/
          return_hash = return_hash[pathy.gsub(":", "").to_sym]
        else
          return_hash = return_hash[pathy]
        end
      end

      return_hash.extend InstanceMethods
      return_hash.walky_path = path

      return_hash
    end

    def self.extract(hash, path)
      Walky.move(hash, path)
    end

    def self.extract_with_sym(hash, path)
      symbolize_keys(extract(hash, path))
    end

    def self.symbolize_keys(hash)
      {}.tap do |h|
        hash.each do |key, value|
          h[key.to_sym] = value
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
walky-0.0.1 lib/walky/parser.rb