Class: RBS::AST::Declarations::Module::Self

Inherits:
Object
  • Object
show all
Includes:
_ToJson, _HashEqual
Defined in:
lib/rbs/ast/declarations.rb,
sig/declarations.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, args:, location:) ⇒ Self

Returns a new instance of Self.

Parameters:

  • name: (TypeName)
  • args: (Array[Types::t])
  • location: (loc, nil)


153
154
155
156
157
# File 'lib/rbs/ast/declarations.rb', line 153

def initialize(name:, args:, location:)
  @name = name
  @args = args
  @location = location
end

Instance Attribute Details

#argsArray[Types::t] (readonly)

Returns the value of attribute args.

Returns:

  • (Array[Types::t])


150
151
152
# File 'lib/rbs/ast/declarations.rb', line 150

def args
  @args
end

#locationloc? (readonly)

Returns the value of attribute location.

Returns:

  • (loc, nil)


151
152
153
# File 'lib/rbs/ast/declarations.rb', line 151

def location
  @location
end

#nameTypeName (readonly)

Returns the value of attribute name.

Returns:



149
150
151
# File 'lib/rbs/ast/declarations.rb', line 149

def name
  @name
end

Instance Method Details

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



159
160
161
# File 'lib/rbs/ast/declarations.rb', line 159

def ==(other)
  other.is_a?(Self) && other.name == name && other.args == args
end

#hashObject



165
166
167
# File 'lib/rbs/ast/declarations.rb', line 165

def hash
  self.class.hash ^ name.hash ^ args.hash ^ location.hash
end

#to_json(state = nil) ⇒ Object



169
170
171
172
173
174
175
# File 'lib/rbs/ast/declarations.rb', line 169

def to_json(state = nil)
  {
    name: name,
    args: args,
    location: location
  }.to_json(state)
end

#to_sString

Returns:

  • (String)


177
178
179
180
181
182
183
# File 'lib/rbs/ast/declarations.rb', line 177

def to_s
  if args.empty?
    name.to_s
  else
    "#{name}[#{args.join(", ")}]"
  end
end