Class: Liquid::Tokenizer

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid/tokenizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_numberObject (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

#shiftObject



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