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

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

Defined Under Namespace

Classes: Super

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type_params:, super_class:, members:, annotations:, location:, comment:) ⇒ Class

Returns a new instance of Class.



116
117
118
119
120
121
122
123
124
# File 'lib/rbs/ast/declarations.rb', line 116

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.



112
113
114
# File 'lib/rbs/ast/declarations.rb', line 112

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



113
114
115
# File 'lib/rbs/ast/declarations.rb', line 113

def location
  @location
end

#membersObject (readonly)

Returns the value of attribute members.



110
111
112
# File 'lib/rbs/ast/declarations.rb', line 110

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



108
109
110
# File 'lib/rbs/ast/declarations.rb', line 108

def name
  @name
end

#super_classObject (readonly)

Returns the value of attribute super_class.



111
112
113
# File 'lib/rbs/ast/declarations.rb', line 111

def super_class
  @super_class
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



109
110
111
# File 'lib/rbs/ast/declarations.rb', line 109

def type_params
  @type_params
end

Instance Method Details

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



126
127
128
129
130
131
132
# File 'lib/rbs/ast/declarations.rb', line 126

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

#hashObject



136
137
138
# File 'lib/rbs/ast/declarations.rb', line 136

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

#to_json(*a) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/rbs/ast/declarations.rb', line 140

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