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

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

Defined Under Namespace

Classes: Super

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:, super_class:, members:, annotations:, location:, comment:) ⇒ Class

Returns a new instance of Class.



168
169
170
171
172
173
174
175
176
# File 'lib/rbs/ast/declarations.rb', line 168

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

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



164
165
166
# File 'lib/rbs/ast/declarations.rb', line 164

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



166
167
168
# File 'lib/rbs/ast/declarations.rb', line 166

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



165
166
167
# File 'lib/rbs/ast/declarations.rb', line 165

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



162
163
164
# File 'lib/rbs/ast/declarations.rb', line 162

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



160
161
162
# File 'lib/rbs/ast/declarations.rb', line 160

def name
  @name
end

#super_classObject (readonly)

Returns the value of attribute super_class.



163
164
165
# File 'lib/rbs/ast/declarations.rb', line 163

def super_class
  @super_class
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



161
162
163
# File 'lib/rbs/ast/declarations.rb', line 161

def type_params
  @type_params
end

Instance Method Details

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



178
179
180
181
182
183
184
# File 'lib/rbs/ast/declarations.rb', line 178

def ==(other)
  other.is_a?(Class) &&
    other.name == name &&
    other.type_params == type_params &&
    other.super_class == super_class &&
    other.members == members
end

#hashObject



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

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

#to_json(*a) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rbs/ast/declarations.rb', line 192

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