Class: Rucoa::Yard::DefinitionGenerators::ConstantAssignmentDefinitionGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rucoa/yard/definition_generators/constant_assignment_definition_generator.rb

Instance Method Summary collapse

Methods inherited from Base

call, #initialize

Constructor Details

This class inherits a constructor from Rucoa::Yard::DefinitionGenerators::Base

Instance Method Details

#callObject

Examples:

returns constant definition for constant assignment node

definitions = Rucoa::Source.new(
  content: <<~RUBY,
    Foo = 'foo'
  RUBY
  uri: '/path/to/foo.rb'
).definitions
expect(definitions[0]).to be_a(Rucoa::Definitions::ConstantDefinition)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rucoa/yard/definition_generators/constant_assignment_definition_generator.rb', line 15

def call
  return [] unless @node.is_a?(Nodes::CasgnNode)

  [
    Definitions::ConstantDefinition.new(
      description: description,
      location: location,
      qualified_name: @node.qualified_name
    )
  ]
end