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.



139
140
141
142
143
# File 'lib/rbs/ast/declarations.rb', line 139

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



136
137
138
# File 'lib/rbs/ast/declarations.rb', line 136

def args
  @args
end

#locationObject (readonly)

Returns the value of attribute location.



137
138
139
# File 'lib/rbs/ast/declarations.rb', line 137

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



135
136
137
# File 'lib/rbs/ast/declarations.rb', line 135

def name
  @name
end

Instance Method Details

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



145
146
147
# File 'lib/rbs/ast/declarations.rb', line 145

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/rbs/ast/declarations.rb', line 155

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

#to_sObject



163
164
165
166
167
168
169
# File 'lib/rbs/ast/declarations.rb', line 163

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