Sha256: eae9ca117f70801fa53f21ba003a3e639622f8907cf17d98694ff6b96d966c06
Contents?: true
Size: 819 Bytes
Versions: 2
Compression:
Stored size: 819 Bytes
Contents
module Analyst module Entities class Hash < Entity handles_node :hash def pairs @pairs ||= process_nodes(ast.children) end # Convenience method to turn this Entity into an actual ::Hash. # If `extract_values` is true, then all keys and values that respond # to `#value` will be replaced by the value they return from that call. # Otherwise they'll be left as Analyst::Entities::Entity objects. def to_hash(extract_values:true) pairs.inject({}) do |hash, pair| key = pair.key val = pair.value if extract_values key = key.value if key.respond_to?(:value) val = val.value if val.respond_to?(:value) end hash[key] = val hash end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
analyst-0.16.1 | lib/analyst/entities/hash.rb |
analyst-0.15.0 | lib/analyst/entities/hash.rb |