Class: RBS::AST::Declarations::Extension

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type_params:, extension_name:, members:, annotations:, location:, comment:) ⇒ Extension

Returns a new instance of Extension.



202
203
204
205
206
207
208
209
210
# File 'lib/rbs/ast/declarations.rb', line 202

def initialize(name:, type_params:, extension_name:, members:, annotations:, location:, comment:)
  @name = name
  @type_params = type_params
  @extension_name = extension_name
  @members = members
  @annotations = annotations
  @location = location
  @comment = comment
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



198
199
200
# File 'lib/rbs/ast/declarations.rb', line 198

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



200
201
202
# File 'lib/rbs/ast/declarations.rb', line 200

def comment
  @comment
end

#extension_nameObject (readonly)

Returns the value of attribute extension_name.



196
197
198
# File 'lib/rbs/ast/declarations.rb', line 196

def extension_name
  @extension_name
end

#locationObject (readonly)

Returns the value of attribute location.



199
200
201
# File 'lib/rbs/ast/declarations.rb', line 199

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



197
198
199
# File 'lib/rbs/ast/declarations.rb', line 197

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



194
195
196
# File 'lib/rbs/ast/declarations.rb', line 194

def name
  @name
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



195
196
197
# File 'lib/rbs/ast/declarations.rb', line 195

def type_params
  @type_params
end

Instance Method Details

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



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

def ==(other)
  other.is_a?(Extension) &&
    other.name == name &&
    other.type_params == type_params &&
    other.extension_name == extension_name &&
    other.members == members
end

#hashObject



222
223
224
# File 'lib/rbs/ast/declarations.rb', line 222

def hash
  self.class.hash ^ name.hash ^ type_params.hash ^ extension_name.hash ^ members.hash
end

#to_json(*a) ⇒ Object



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/rbs/ast/declarations.rb', line 226

def to_json(*a)
  {
    declaration: :extension,
    name: name,
    type_params: type_params,
    extension_name: extension_name,
    members: members,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(*a)
end