Class: SyntaxTree::CSS::Declaration

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

Overview

Declarations are a particular instance of associating a property or descriptor name with a value. www.w3.org/TR/css-syntax-3/#declaration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(name:, value:, important:, location:) ⇒ Declaration

Returns a new instance of Declaration.



385
386
387
388
389
390
# File 'lib/syntax_tree/css/nodes.rb', line 385

def initialize(name:, value:, important:, location:)
  @name = name
  @value = value
  @important = important
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



383
384
385
# File 'lib/syntax_tree/css/nodes.rb', line 383

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



383
384
385
# File 'lib/syntax_tree/css/nodes.rb', line 383

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



383
384
385
# File 'lib/syntax_tree/css/nodes.rb', line 383

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



392
393
394
# File 'lib/syntax_tree/css/nodes.rb', line 392

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

#child_nodesObject Also known as: deconstruct



396
397
398
# File 'lib/syntax_tree/css/nodes.rb', line 396

def child_nodes
  value
end

#deconstruct_keys(keys) ⇒ Object



402
403
404
# File 'lib/syntax_tree/css/nodes.rb', line 402

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

#important?Boolean

Returns:

  • (Boolean)


406
407
408
# File 'lib/syntax_tree/css/nodes.rb', line 406

def important?
  @important
end