Class: RBS::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/constant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, entry:) ⇒ Constant

Returns a new instance of Constant.



7
8
9
10
11
# File 'lib/rbs/constant.rb', line 7

def initialize(name:, type:, entry:)
  @name = name
  @type = type
  @entry = entry
end

Instance Attribute Details

#declarationObject (readonly)

Returns the value of attribute declaration.



5
6
7
# File 'lib/rbs/constant.rb', line 5

def declaration
  @declaration
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rbs/constant.rb', line 3

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/rbs/constant.rb', line 4

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



13
14
15
16
17
18
# File 'lib/rbs/constant.rb', line 13

def ==(other)
  other.is_a?(Constant) &&
    other.name == name &&
    other.type == type &&
    other.entry == entry
end

#hashObject



22
23
24
# File 'lib/rbs/constant.rb', line 22

def hash
  self.class.hash ^ name.hash ^ type.hash ^ entry.hash
end