Method: Parser::Source::Map#to_hash
- Defined in:
- lib/parser/source/map.rb
#to_hash ⇒ Hash<Symbol, Parser::Source::Range>
Converts this source map to a hash with keys corresponding to ranges. For example, if called on an instance of Collection, which adds the ‘begin` and `end` ranges, the resulting hash will contain keys `:expression`, `:begin` and `:end`.
166 167 168 169 170 171 172 |
# File 'lib/parser/source/map.rb', line 166 def to_hash instance_variables.inject({}) do |hash, ivar| next hash if ivar.to_sym == :@node hash[ivar[1..-1].to_sym] = instance_variable_get(ivar) hash end end |