module Str2Hash::String

Public Instance Methods

to_h() click to toggle source

Converts the string to a hash representation @return [Hash] Hash representation of the string @raise [Parslet::ParseFailed] If parsing of the string fails

@example

"{ :foo => 'bar'}".to_h
=> {:foo=>"bar"}
# File lib/str2hash.rb, line 152
def to_h

  p = HashParse.new
  t = HashTransform.new

  h_str = self.clone
  h_str.strip!
  t.apply(p.parse(self.strip))

end