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.



183
184
185
186
187
188
189
190
191
# File 'lib/rbs/ast/declarations.rb', line 183

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.



179
180
181
# File 'lib/rbs/ast/declarations.rb', line 179

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



181
182
183
# File 'lib/rbs/ast/declarations.rb', line 181

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



178
179
180
# File 'lib/rbs/ast/declarations.rb', line 178

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



177
178
179
# File 'lib/rbs/ast/declarations.rb', line 177

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



175
176
177
# File 'lib/rbs/ast/declarations.rb', line 175

def name
  @name
end

#self_typesObject (readonly)

Returns the value of attribute self_types.



180
181
182
# File 'lib/rbs/ast/declarations.rb', line 180

def self_types
  @self_types
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



176
177
178
# File 'lib/rbs/ast/declarations.rb', line 176

def type_params
  @type_params
end

Instance Method Details

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



193
194
195
196
197
198
199
# File 'lib/rbs/ast/declarations.rb', line 193

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

#hashObject



203
204
205
# File 'lib/rbs/ast/declarations.rb', line 203

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

#to_json(state = _ = nil) ⇒ Object



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

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