Class: Liquid::Tokenizer
- Inherits:
-
Object
- Object
- Liquid::Tokenizer
- Defined in:
- lib/liquid/tokenizer.rb
Instance Attribute Summary collapse
-
#for_liquid_tag ⇒ Object
readonly
Returns the value of attribute for_liquid_tag.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
Instance Method Summary collapse
-
#initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #shift ⇒ Object
Constructor Details
#initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false) ⇒ Tokenizer
Returns a new instance of Tokenizer.
7 8 9 10 11 12 13 |
# File 'lib/liquid/tokenizer.rb', line 7 def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false) @source = source @line_number = line_number || (line_numbers ? 1 : nil) @for_liquid_tag = for_liquid_tag @offset = 0 @tokens = tokenize end |
Instance Attribute Details
#for_liquid_tag ⇒ Object (readonly)
Returns the value of attribute for_liquid_tag.
5 6 7 |
# File 'lib/liquid/tokenizer.rb', line 5 def for_liquid_tag @for_liquid_tag end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/liquid/tokenizer.rb', line 5 def line_number @line_number end |
Instance Method Details
#shift ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/liquid/tokenizer.rb', line 15 def shift token = @tokens[@offset] return nil unless token @offset += 1 if @line_number @line_number += @for_liquid_tag ? 1 : token.count("\n") end token end |