Class: Yardcheck::Documentation::MethodObject
- Inherits:
-
Object
- Object
- Yardcheck::Documentation::MethodObject
- Includes:
- Adamantium::Flat
- Defined in:
- lib/yardcheck/documentation/method_object.rb
Instance Method Summary collapse
- #location ⇒ Object
- #location_pointer ⇒ Object
- #method_identifier ⇒ Object
- #namespace ⇒ Object
- #params ⇒ Object
- #predicate_method? ⇒ Boolean
- #processed_source ⇒ Object
- #raise_type ⇒ Object
- #return_type ⇒ Object
- #scope ⇒ Object
- #selector ⇒ Object
- #shorthand ⇒ Object
- #singleton? ⇒ Boolean
- #source ⇒ Object
- #warnings ⇒ Object
Instance Method Details
#location ⇒ Object
38 39 40 |
# File 'lib/yardcheck/documentation/method_object.rb', line 38 def location [yardoc.file, yardoc.line] end |
#location_pointer ⇒ Object
54 55 56 |
# File 'lib/yardcheck/documentation/method_object.rb', line 54 def location_pointer location.join(':') end |
#method_identifier ⇒ Object
42 43 44 |
# File 'lib/yardcheck/documentation/method_object.rb', line 42 def method_identifier [namespace, selector, scope] end |
#namespace ⇒ Object
12 13 14 |
# File 'lib/yardcheck/documentation/method_object.rb', line 12 def namespace singleton? ? unscoped_namespace.singleton_class : unscoped_namespace end |
#params ⇒ Object
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
65 66 67 |
# File 'lib/yardcheck/documentation/method_object.rb', line 65 def predicate_method? selector.to_s.end_with?('?') end |
#processed_source ⇒ Object
69 70 71 |
# File 'lib/yardcheck/documentation/method_object.rb', line 69 def processed_source ProcessedSource.new(yardoc.source) end |
#raise_type ⇒ Object
26 27 28 |
# File 'lib/yardcheck/documentation/method_object.rb', line 26 def raise_type raise_typedef unless raise_typedef&.invalid_const? end |
#return_type ⇒ Object
22 23 24 |
# File 'lib/yardcheck/documentation/method_object.rb', line 22 def return_type return_typedef unless return_typedef&.invalid_const? end |
#scope ⇒ Object
34 35 36 |
# File 'lib/yardcheck/documentation/method_object.rb', line 34 def scope yardoc.scope end |
#selector ⇒ Object
8 9 10 |
# File 'lib/yardcheck/documentation/method_object.rb', line 8 def selector yardoc.name end |
#shorthand ⇒ Object
46 47 48 |
# File 'lib/yardcheck/documentation/method_object.rb', line 46 def shorthand "#{namespace}##{selector}" end |
#singleton? ⇒ Boolean
30 31 32 |
# File 'lib/yardcheck/documentation/method_object.rb', line 30 def singleton? scope.equal?(:class) end |
#source ⇒ Object
50 51 52 |
# File 'lib/yardcheck/documentation/method_object.rb', line 50 def source [documentation_source, yardoc.source].join("\n") end |
#warnings ⇒ Object
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 |