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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Self.



212
213
214
215
216
# File 'lib/rbs/ast/declarations.rb', line 212

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



209
210
211
# File 'lib/rbs/ast/declarations.rb', line 209

def args
  @args
end

#locationObject (readonly)

Returns the value of attribute location.



210
211
212
# File 'lib/rbs/ast/declarations.rb', line 210

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



208
209
210
# File 'lib/rbs/ast/declarations.rb', line 208

def name
  @name
end

Instance Method Details

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



218
219
220
# File 'lib/rbs/ast/declarations.rb', line 218

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

#hashObject



224
225
226
# File 'lib/rbs/ast/declarations.rb', line 224

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

#to_json(*a) ⇒ Object



228
229
230
231
232
233
234
# File 'lib/rbs/ast/declarations.rb', line 228

def to_json(*a)
  {
    name: name,
    args: args,
    location: location
  }.to_json(*a)
end

#to_sObject



236
237
238
239
240
241
242
# File 'lib/rbs/ast/declarations.rb', line 236

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