Class: Yardcheck::Documentation::MethodObject

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/yardcheck/documentation/method_object.rb

Instance Method Summary collapse

Instance Method Details

#locationObject



38
39
40
# File 'lib/yardcheck/documentation/method_object.rb', line 38

def location
  [yardoc.file, yardoc.line]
end

#location_pointerObject



54
55
56
# File 'lib/yardcheck/documentation/method_object.rb', line 54

def location_pointer
  location.join(':')
end

#method_identifierObject



42
43
44
# File 'lib/yardcheck/documentation/method_object.rb', line 42

def method_identifier
  [namespace, selector, scope]
end

#namespaceObject



12
13
14
# File 'lib/yardcheck/documentation/method_object.rb', line 12

def namespace
  singleton? ? unscoped_namespace.singleton_class : unscoped_namespace
end

#paramsObject



17
18
19
# File 'lib/yardcheck/documentation/method_object.rb', line 17

def params
  param_typedefs.select { |key, value| key && !value.invalid_const? }
end

#predicate_method?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/yardcheck/documentation/method_object.rb', line 65

def predicate_method?
  selector.to_s.end_with?('?')
end

#processed_sourceObject



69
70
71
# File 'lib/yardcheck/documentation/method_object.rb', line 69

def processed_source
  ProcessedSource.new(yardoc.source)
end

#raise_typeObject



26
27
28
# File 'lib/yardcheck/documentation/method_object.rb', line 26

def raise_type
  raise_typedef unless raise_typedef&.invalid_const?
end

#return_typeObject



22
23
24
# File 'lib/yardcheck/documentation/method_object.rb', line 22

def return_type
  return_typedef unless return_typedef&.invalid_const?
end

#scopeObject



34
35
36
# File 'lib/yardcheck/documentation/method_object.rb', line 34

def scope
  yardoc.scope
end

#selectorObject



8
9
10
# File 'lib/yardcheck/documentation/method_object.rb', line 8

def selector
  yardoc.name
end

#shorthandObject



46
47
48
# File 'lib/yardcheck/documentation/method_object.rb', line 46

def shorthand
  "#{namespace}##{selector}"
end

#singleton?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/yardcheck/documentation/method_object.rb', line 30

def singleton?
  scope.equal?(:class)
end

#sourceObject



50
51
52
# File 'lib/yardcheck/documentation/method_object.rb', line 50

def source
  [documentation_source, yardoc.source].join("\n")
end

#warningsObject



58
59
60
61
62
63
# File 'lib/yardcheck/documentation/method_object.rb', line 58

def warnings
  param_warnings = param_typedefs.select { |_, typedef| typedef.invalid_const? }.values
  return_warning = return_typedef if return_typedef&.invalid_const?

  [*param_warnings, *return_warning].map { |warning| Warning.new(self, warning) }
end