Class: ASTUtils::Labeling::LabeledName

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, label:) ⇒ LabeledName

Returns a new instance of LabeledName.



7
8
9
10
# File 'lib/ast_utils/labeling.rb', line 7

def initialize(name:, label:)
  @name = name
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/ast_utils/labeling.rb', line 5

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/ast_utils/labeling.rb', line 20

def ==(other)
  other.is_a?(LabeledName) && other.name == name && other.label == label
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ast_utils/labeling.rb', line 28

def eql?(other)
  self == other
end

#equal?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ast_utils/labeling.rb', line 24

def equal?(other)
  self == other
end

#hashObject



16
17
18
# File 'lib/ast_utils/labeling.rb', line 16

def hash
  name.hash ^ label.hash
end

#inspectObject



12
13
14
# File 'lib/ast_utils/labeling.rb', line 12

def inspect
  "#{name}@#{label}"
end