Class: Liquid::Tokenizer
- Inherits:
-
Object
- Object
- Liquid::Tokenizer
- Defined in:
- lib/liquid/tokenizer.rb
Instance Attribute Summary collapse
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
Instance Method Summary collapse
-
#initialize(source, line_numbers = false) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #shift ⇒ Object
Constructor Details
#initialize(source, line_numbers = false) ⇒ Tokenizer
Returns a new instance of Tokenizer.
5 6 7 8 9 |
# File 'lib/liquid/tokenizer.rb', line 5 def initialize(source, line_numbers = false) @source = source @line_number = line_numbers ? 1 : nil @tokens = tokenize end |
Instance Attribute Details
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
3 4 5 |
# File 'lib/liquid/tokenizer.rb', line 3 def line_number @line_number end |
Instance Method Details
#shift ⇒ Object
11 12 13 14 15 |
# File 'lib/liquid/tokenizer.rb', line 11 def shift token = @tokens.shift @line_number += token.count("\n") if @line_number && token token end |