Class: ASTUtils::Scope::Assignment

Inherits:
Object
  • Object
show all
Defined in:
lib/ast_utils/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:, variable:) ⇒ Assignment

Returns a new instance of Assignment.



6
7
8
9
# File 'lib/ast_utils/scope.rb', line 6

def initialize(node:, variable:)
  @node = node
  @variable = variable
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/ast_utils/scope.rb', line 4

def node
  @node
end

#variableObject (readonly)

Returns the value of attribute variable.



4
5
6
# File 'lib/ast_utils/scope.rb', line 4

def variable
  @variable
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/ast_utils/scope.rb', line 19

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ast_utils/scope.rb', line 15

def eql?(other)
  other.is_a?(Assignment) && other.node.__id__ == node.__id__ && other.variable == variable
end

#hashObject



11
12
13
# File 'lib/ast_utils/scope.rb', line 11

def hash
  node.__id__ ^ variable.hash
end