Class: Estreet::VariableDeclaration

Inherits:
Statement show all
Defined in:
lib/estreet/variable_declaration.rb

Instance Attribute Summary

Attributes inherited from Node

#source_location

Instance Method Summary collapse

Methods inherited from Statement

#<<, #to_statement

Methods inherited from Node

#as_json, #loc, #type

Constructor Details

#initialize(declarations) ⇒ VariableDeclaration

Returns a new instance of VariableDeclaration.

Raises:

  • (TypeError)


3
4
5
6
7
# File 'lib/estreet/variable_declaration.rb', line 3

def initialize(declarations)
  raise TypeError unless declarations.all? {|d| d.is_a? VariableDeclarator}

  @declarations = declarations
end

Instance Method Details

#attributesObject



9
10
11
# File 'lib/estreet/variable_declaration.rb', line 9

def attributes
  super.merge(declarations: @declarations, kind: "var".freeze)
end

#to_declarationObject



13
14
15
# File 'lib/estreet/variable_declaration.rb', line 13

def to_declaration
  self
end