Class: Rucoa::Rbs::RubyDefinitionsLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rucoa/rbs/ruby_definitions_loader.rb

Overview

Load definitions for Ruby core and standard libraries.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callArray<Rucoa::Definitions::Base>

Returns:



11
12
13
# File 'lib/rucoa/rbs/ruby_definitions_loader.rb', line 11

def call
  new.call
end

Instance Method Details

#callArray<Rucoa::Definitions::Base>

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rucoa/rbs/ruby_definitions_loader.rb', line 17

def call
  declarations.flat_map do |declaration|
    case declaration
    when ::RBS::AST::Declarations::Constant
      [ConstantDefinitionMapper.call(declaration: declaration)]
    when ::RBS::AST::Declarations::Class
      [ClassDefinitionMapper.call(declaration: declaration)] +
        declaration.members.grep(::RBS::AST::Members::MethodDefinition).map do |method_definition|
          MethodDefinitionMapper.call(
            declaration: declaration,
            method_definition: method_definition
          )
        end
    when ::RBS::AST::Declarations::Module
      [ModuleDefinitionMapper.call(declaration: declaration)] +
        declaration.members.grep(::RBS::AST::Members::MethodDefinition).map do |method_definition|
          MethodDefinitionMapper.call(
            declaration: declaration,
            method_definition: method_definition
          )
        end
    else
      []
    end
  end
end