Class: RBS::AST::Ruby::Declarations::ModuleDecl

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

Instance Attribute Summary collapse

Attributes inherited from Base

#buffer

Instance Method Summary collapse

Methods included from Helpers::LocationHelper

#rbs_location

Methods included from Helpers::ConstantHelper

constant_as_type_name

Constructor Details

#initialize(buffer, name, node) ⇒ ModuleDecl

Returns a new instance of ModuleDecl.



121
122
123
124
125
126
# File 'lib/rbs/ast/ruby/declarations.rb', line 121

def initialize(buffer, name, node)
  super(buffer)
  @module_name = name
  @node = node
  @members = []
end

Instance Attribute Details

#membersObject (readonly)

Returns the value of attribute members.



117
118
119
# File 'lib/rbs/ast/ruby/declarations.rb', line 117

def members
  @members
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



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

def module_name
  @module_name
end

#nodeObject (readonly)

Returns the value of attribute node.



119
120
121
# File 'lib/rbs/ast/ruby/declarations.rb', line 119

def node
  @node
end

Instance Method Details

#each_decl(&block) ⇒ Object



128
129
130
131
132
133
134
135
136
# File 'lib/rbs/ast/ruby/declarations.rb', line 128

def each_decl(&block)
  return enum_for(:each_decl) unless block

  @members.each do |member|
    if member.is_a?(Base)
      yield member
    end
  end
end

#locationObject



142
143
144
# File 'lib/rbs/ast/ruby/declarations.rb', line 142

def location
  rbs_location(node.location)
end

#name_locationObject



146
147
148
# File 'lib/rbs/ast/ruby/declarations.rb', line 146

def name_location
  rbs_location(node.constant_path.location)
end

#self_typesObject



140
# File 'lib/rbs/ast/ruby/declarations.rb', line 140

def self_types = []

#type_fingerprintObject



150
151
152
153
154
155
156
157
158
# File 'lib/rbs/ast/ruby/declarations.rb', line 150

def type_fingerprint
  result = [] #: Array[untyped]

  result << "decls/module"
  result << module_name.to_s
  result << members.map { _1.type_fingerprint}

  result
end

#type_paramsObject



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

def type_params = []