Exception: TypeError

Inherits:
Exception
  • Object
show all
Defined in:
lib/dsl/monkeypatches.rb

Overview

Helper for parsing type errors in machine-readable format.

Instance Method Summary collapse

Instance Method Details

#type_dataHash

Parses the error string and returns the machine-readable expected arguments classes.

Returns:

  • (Hash)

    consisting of two strings representing given and required argument types.



194
195
196
197
198
199
200
# File 'lib/dsl/monkeypatches.rb', line 194

def type_data
  # ⇒ can't convert Hash into Integer
  # There are two ways to match: either rely on us locale, or find the uppercased classes
  /[^[A-Z]]*(?<given>[A-Z]\w*)[^[A-Z]]*(?<required>[A-Z]\w*)/.match(self.to_s) { |m|
    { :given => m[:given], :required => m[:required] }
  }
end