Class: StringScanner

Inherits:
Object show all
Defined in:
lib/strscan/substr.rb

Instance Method Summary collapse

Instance Method Details

#substr(start, end_) ⇒ String

Parameters:

  • start (Integer)

    some value of #pos.

  • end_ (Integer)

    some value of #pos.

Returns:

  • (String)


7
8
9
10
11
12
13
# File 'lib/strscan/substr.rb', line 7

def substr(start, end_)
  old_pos = self.pos
  self.pos = start
  result = peek(end_ - start)
  self.pos = old_pos
  return result
end