class PhpSerialization::Tokenizer

Public Class Methods

new(string) click to toggle source
# File lib/php_serialization/tokenizer.rb, line 3
def initialize(string)
  @string = string
end

Public Instance Methods

each() { |:NUMBER, $&| ... } click to toggle source
# File lib/php_serialization/tokenizer.rb, line 7
def each
  while !@string.empty?
    token = case @string
    when /\A-?[0-9]+(\.[0-9]+)?/m then yield([:NUMBER, $&])
    when /\A"((?:(?:"(?![;:]))*|(?:[^"]))*)"(?=[:;])/m then yield([:STRING, $1])
    when /\A[^\s]/m             then yield([$&, $&])
    end

    @string = $'
  end

  yield([false, '$'])
end