Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/funit/assertions.rb
Overview
Thanks to James Edward Gray II by way of ruby-talk mailing list
Instance Method Summary collapse
Instance Method Details
#get_args ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/funit/assertions.rb', line 16 def get_args scanner = StringScanner.new(self) result = scanner.eos? ? Array.new : [""] paren_depth = 0 until scanner.eos? if scanner.scan(/[^(),]+/) # do nothing--we found the part of the argument we need to add elsif scanner.scan(/\(/) paren_depth += 1 elsif scanner.scan(/\)/) paren_depth -= 1 elsif scanner.scan(/,\s*/) and paren_depth.zero? result << "" next end result.last << scanner.matched end result end |