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

Inherits:
Base
  • Object
show all
Includes:
MixinHelper, NestedDeclarationHelper
Defined in:
lib/rbs/ast/declarations.rb

Defined Under Namespace

Classes: Self

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MixinHelper

#each_mixin

Methods included from NestedDeclarationHelper

#each_decl, #each_member

Constructor Details

#initialize(name:, type_params:, members:, self_types:, annotations:, location:, comment:) ⇒ Module

Returns a new instance of Module.



197
198
199
200
201
202
203
204
205
# File 'lib/rbs/ast/declarations.rb', line 197

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

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



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

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



192
193
194
# File 'lib/rbs/ast/declarations.rb', line 192

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



191
192
193
# File 'lib/rbs/ast/declarations.rb', line 191

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



189
190
191
# File 'lib/rbs/ast/declarations.rb', line 189

def name
  @name
end

#self_typesObject (readonly)

Returns the value of attribute self_types.



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

def self_types
  @self_types
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



190
191
192
# File 'lib/rbs/ast/declarations.rb', line 190

def type_params
  @type_params
end

Instance Method Details

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



220
221
222
223
224
225
226
# File 'lib/rbs/ast/declarations.rb', line 220

def ==(other)
  other.is_a?(Module) &&
    other.name == name &&
    other.type_params == type_params &&
    other.self_types == self_types &&
    other.members == members
end

#hashObject



230
231
232
# File 'lib/rbs/ast/declarations.rb', line 230

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

#to_json(state = _ = nil) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/rbs/ast/declarations.rb', line 234

def to_json(state = _ = nil)
  {
    declaration: :module,
    name: name,
    type_params: type_params,
    members: members,
    self_types: self_types,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(state)
end

#update(name: self.name, type_params: self.type_params, members: self.members, self_types: self.self_types, annotations: self.annotations, location: self.location, comment: self.comment) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/rbs/ast/declarations.rb', line 207

def update(name: self.name, type_params: self.type_params, members: self.members, self_types: self.self_types, annotations: self.annotations, location: self.location, comment: self.comment)
  self.class.new(
    name: name,
    type_params: type_params,
    members: members,
    self_types: self_types,
    annotations: annotations,
    location: location,
    comment: comment
  )
end