Class: SyntaxTree::CSS::CommentToken

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

Overview

A parsed token that contains a comment. These aren’t actually declared in the spec because it assumes you can just drop them. We parse them into tokens, however, so that we can keep track of their location.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:, location:) ⇒ CommentToken

Returns a new instance of CommentToken.



334
335
336
337
# File 'lib/syntax_tree/css/nodes.rb', line 334

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



332
333
334
# File 'lib/syntax_tree/css/nodes.rb', line 332

def location
  @location
end

#valueObject (readonly)

Returns the value of attribute value.



332
333
334
# File 'lib/syntax_tree/css/nodes.rb', line 332

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



339
340
341
# File 'lib/syntax_tree/css/nodes.rb', line 339

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

#child_nodesObject Also known as: deconstruct



343
344
345
# File 'lib/syntax_tree/css/nodes.rb', line 343

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



349
350
351
# File 'lib/syntax_tree/css/nodes.rb', line 349

def deconstruct_keys(keys)
  { value: value, location: location }
end