Class: SyntaxTree::CSS::EOFToken

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/css/nodes.rb

Overview

A conceptual token representing the end of the list of tokens. Whenever the list of tokens is empty, the next input token is always an EOFToken. www.w3.org/TR/css-syntax-3/#typedef-eof-token

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(location:) ⇒ EOFToken

Returns a new instance of EOFToken.



469
470
471
# File 'lib/syntax_tree/css/nodes.rb', line 469

def initialize(location:)
  @location = Location.from(location)
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



467
468
469
# File 'lib/syntax_tree/css/nodes.rb', line 467

def location
  @location
end

Class Method Details

.[](index) ⇒ Object

Since we create EOFToken objects a lot with ranges that are empty, it’s nice to have this convenience method.



489
490
491
# File 'lib/syntax_tree/css/nodes.rb', line 489

def self.[](index)
  new(location: index...index)
end

Instance Method Details

#accept(visitor) ⇒ Object



473
474
475
# File 'lib/syntax_tree/css/nodes.rb', line 473

def accept(visitor)
  visitor.visit_eof_token(self)
end

#child_nodesObject Also known as: deconstruct



477
478
479
# File 'lib/syntax_tree/css/nodes.rb', line 477

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



483
484
485
# File 'lib/syntax_tree/css/nodes.rb', line 483

def deconstruct_keys(keys)
  { location: location }
end