Class: SyntaxTree::CSS::DimensionToken

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

Overview

A parsed token that contains a numeric value with a dimension. www.w3.org/TR/css-syntax-3/#typedef-dimension-token

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:, unit:, type:, location:) ⇒ DimensionToken

Returns a new instance of DimensionToken.



441
442
443
444
445
446
# File 'lib/syntax_tree/css/nodes.rb', line 441

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



439
440
441
# File 'lib/syntax_tree/css/nodes.rb', line 439

def location
  @location
end

#typeObject (readonly)

Returns the value of attribute type.



439
440
441
# File 'lib/syntax_tree/css/nodes.rb', line 439

def type
  @type
end

#unitObject (readonly)

Returns the value of attribute unit.



439
440
441
# File 'lib/syntax_tree/css/nodes.rb', line 439

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



439
440
441
# File 'lib/syntax_tree/css/nodes.rb', line 439

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



448
449
450
# File 'lib/syntax_tree/css/nodes.rb', line 448

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

#child_nodesObject Also known as: deconstruct



452
453
454
# File 'lib/syntax_tree/css/nodes.rb', line 452

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



458
459
460
# File 'lib/syntax_tree/css/nodes.rb', line 458

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