Exception: ArgumentError
- Inherits:
-
Exception
- Object
- Exception
- ArgumentError
- Defined in:
- lib/dsl/monkeypatches.rb
Overview
Helper for parsing argument errors in machine-readable collection.
Instance Method Summary collapse
-
#argument_data ⇒ Hash
Parses the error string and returns the machine-readable argument count contract.
Instance Method Details
#argument_data ⇒ Hash
Parses the error string and returns the machine-readable argument count contract. minimal required and (if makes sense) maximal.
175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/dsl/monkeypatches.rb', line 175 def argument_data # ⇒ wrong number of arguments (1 for 2..3) /\((?<given>\d+)\s+\w+\s+(?<min_required>\d+)(?<modifier>\+|\.\.)?(?<max_required>\d+)\)/.match(self.to_s) { |m| { :given => m[:given], :min_required => m[:min_required], :max_required => case m[:modifier] when '+' then '∞' when '..' then h[:max_required] else h[:min_required] end } } end |