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 |
# File 'lib/liquid/tokenizer.rb', line 7 def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false) @source = source.to_s.to_str @line_number = line_number || (line_numbers ? 1 : nil) @for_liquid_tag = for_liquid_tag @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
14 15 16 17 18 19 20 21 22 |
# File 'lib/liquid/tokenizer.rb', line 14 def shift (token = @tokens.shift) || return if @line_number @line_number += @for_liquid_tag ? 1 : token.count("\n") end token end |