Class: RBS::Constant

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Constant.

Parameters:

  • name: (TypeName)
  • type: (Types::t)
  • entry: (constant_entry)


9
10
11
12
13
# File 'lib/rbs/constant.rb', line 9

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

Instance Attribute Details

#entryconstant_entry (readonly)

Returns the value of attribute entry.

Returns:

  • (constant_entry)


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

def entry
  @entry
end

#nameTypeName (readonly)

Returns the value of attribute name.

Returns:



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

def name
  @name
end

#typeTypes::t (readonly)

Returns the value of attribute type.

Returns:

  • (Types::t)


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

def type
  @type
end

Instance Method Details

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

Parameters:

  • other (Object)

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/rbs/constant.rb', line 15

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

#hashInteger

Returns:

  • (Integer)


24
25
26
# File 'lib/rbs/constant.rb', line 24

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