Class: SyntaxTree::ERB::HtmlAttribute

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

Overview

An HtmlAttribute is a key-value pair within a tag. It contains the key, the equals sign, and the value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(key:, equals:, value:, location:) ⇒ HtmlAttribute

Returns a new instance of HtmlAttribute.



392
393
394
395
396
397
# File 'lib/syntax_tree/erb/nodes.rb', line 392

def initialize(key:, equals:, value:, location:)
  @key = key
  @equals = equals
  @value = value
  @location = location
end

Instance Attribute Details

#equalsObject (readonly)

Returns the value of attribute equals.



390
391
392
# File 'lib/syntax_tree/erb/nodes.rb', line 390

def equals
  @equals
end

#keyObject (readonly)

Returns the value of attribute key.



390
391
392
# File 'lib/syntax_tree/erb/nodes.rb', line 390

def key
  @key
end

#locationObject (readonly)

Returns the value of attribute location.



390
391
392
# File 'lib/syntax_tree/erb/nodes.rb', line 390

def location
  @location
end

#valueObject (readonly)

Returns the value of attribute value.



390
391
392
# File 'lib/syntax_tree/erb/nodes.rb', line 390

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



399
400
401
# File 'lib/syntax_tree/erb/nodes.rb', line 399

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

#child_nodesObject Also known as: deconstruct



403
404
405
# File 'lib/syntax_tree/erb/nodes.rb', line 403

def child_nodes
  [key, equals, value]
end

#deconstruct_keys(keys) ⇒ Object



409
410
411
# File 'lib/syntax_tree/erb/nodes.rb', line 409

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