In Files

  • scanf.rb

Parent

Class/Module Index [+]

Quicksearch

String

Public Instance Methods

block_scanf(fstr,&b) click to toggle source
 
               # File scanf.rb, line 701
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) click to toggle source
 
               # File scanf.rb, line 687
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