Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/scanf.rb
Instance Method Summary collapse
Instance Method Details
#block_scanf(fstr, &b) ⇒ Object
684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/scanf.rb', line 684 def block_scanf(fstr,&b) fs = Scanf::FormatString.new(fstr) str = self.dup final = [] begin current = str.scanf(fs) final.push(yield(current)) unless current.empty? str = fs.string_left end until current.empty? || str.empty? return final end |
#scanf(fstr, &b) ⇒ Object
670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/scanf.rb', line 670 def scanf(fstr,&b) if b block_scanf(fstr,&b) else fs = if fstr.is_a? Scanf::FormatString fstr else Scanf::FormatString.new(fstr) end fs.match(self) end end |