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.



95
96
97
98
99
100
101
102
103
# File 'lib/rbs/ast/declarations.rb', line 95

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.



91
92
93
# File 'lib/rbs/ast/declarations.rb', line 91

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



93
94
95
# File 'lib/rbs/ast/declarations.rb', line 93

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



92
93
94
# File 'lib/rbs/ast/declarations.rb', line 92

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



89
90
91
# File 'lib/rbs/ast/declarations.rb', line 89

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



87
88
89
# File 'lib/rbs/ast/declarations.rb', line 87

def name
  @name
end

#super_classObject (readonly)

Returns the value of attribute super_class.



90
91
92
# File 'lib/rbs/ast/declarations.rb', line 90

def super_class
  @super_class
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



88
89
90
# File 'lib/rbs/ast/declarations.rb', line 88

def type_params
  @type_params
end

Instance Method Details

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



105
106
107
108
109
110
111
# File 'lib/rbs/ast/declarations.rb', line 105

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

#hashObject



115
116
117
# File 'lib/rbs/ast/declarations.rb', line 115

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

#to_json(state = _ = nil) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rbs/ast/declarations.rb', line 119

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