Class: MatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/crazy_doll/fixes.rb

Instance Method Summary collapse

Instance Method Details

#to_crazy_doll_params(line) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/crazy_doll/fixes.rb', line 35

def to_crazy_doll_params(line)
  out = {}
  params = (' ' << line).scan(/[^\\](::|\*\*)(\S+)|#{0.chr}([^#{1.chr}]+)#{1.chr}[^#{2.chr}]+#{2.chr}/).flatten.
    map { |x| ['::', '**'].include?(x) ? nil : x }.compact
  params.each_with_index do |key,idx|
    out[key.to_sym] = self[idx+1]
  end
  OpenStruct.new(out)
end