Class: Twig::Token
- Inherits:
- 
      Object
      
        - Object
- Twig::Token
 
- Defined in:
- lib/twig/token.rb
Constant Summary collapse
- EOF_TYPE =
- :eof
- TEXT_TYPE =
- :text
- BLOCK_START_TYPE =
- :block_start
- VAR_START_TYPE =
- :var_start
- BLOCK_END_TYPE =
- :block_end
- VAR_END_TYPE =
- :var_end
- NAME_TYPE =
- :name
- SYMBOL_TYPE =
- :symbol
- NUMBER_TYPE =
- :number
- STRING_TYPE =
- :string
- OPERATOR_TYPE =
- :operator
- PUNCTUATION_TYPE =
- :punctuation
- INTERPOLATION_START_TYPE =
- :interpolation_start
- INTERPOLATION_END_TYPE =
- :interpolation_end
- ARROW_TYPE =
- :arrow
- SPREAD_TYPE =
- :spread
Instance Attribute Summary collapse
- 
  
    
      #lineno  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute lineno. 
- 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute type. 
- 
  
    
      #value  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute value. 
Instance Method Summary collapse
- #debug ⇒ Object
- 
  
    
      #initialize(type, value, lineno)  ⇒ Token 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Token. 
- #test(type, values = nil) ⇒ Object
Constructor Details
#initialize(type, value, lineno) ⇒ Token
Returns a new instance of Token.
| 24 25 26 27 28 | # File 'lib/twig/token.rb', line 24 def initialize(type, value, lineno) @type = type @value = value @lineno = lineno end | 
Instance Attribute Details
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
| 22 23 24 | # File 'lib/twig/token.rb', line 22 def lineno @lineno end | 
#type ⇒ Object (readonly)
Returns the value of attribute type.
| 22 23 24 | # File 'lib/twig/token.rb', line 22 def type @type end | 
#value ⇒ Object (readonly)
Returns the value of attribute value.
| 22 23 24 | # File 'lib/twig/token.rb', line 22 def value @value end | 
Instance Method Details
#debug ⇒ Object
| 44 45 46 | # File 'lib/twig/token.rb', line 44 def debug [type, value] end | 
#test(type, values = nil) ⇒ Object
| 31 32 33 34 35 36 37 38 39 40 41 42 | # File 'lib/twig/token.rb', line 31 def test(type, values = nil) if values.nil? && !type.is_a?(Symbol) values = type type = NAME_TYPE end @type == type && ( values.nil? || (values.is_a?(Array) && values.include?(@value)) || (@value == values) ) end |