Class: RubyPhpSerialization::Tokenizer
- Inherits:
-
Object
- Object
- RubyPhpSerialization::Tokenizer
- Defined in:
- lib/ruby_php_serialization/tokenizer.rb
Instance Method Summary collapse
-
#initialize(string) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #next_token ⇒ Object
Constructor Details
#initialize(string) ⇒ Tokenizer
Returns a new instance of Tokenizer.
3 4 5 |
# File 'lib/ruby_php_serialization/tokenizer.rb', line 3 def initialize(string) @string = string end |
Instance Method Details
#next_token ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby_php_serialization/tokenizer.rb', line 7 def next_token token = nil token = case @string when /\A[0-9]+(\.[0-9]+)?/m then [:NUMBER, $&] when /\A"([^"]*)"/m then [:STRING, $1] when /\A[^\s]/m then [$&, $&] end @string = $' token unless token.nil? end |