Class: Inch::CodeObject::Provider::YARD::Object::MethodObject

Inherits:
Base
  • Object
show all
Defined in:
lib/inch/code_object/provider/yard/object/method_object.rb

Overview

Proxy class for methods

Constant Summary

Constants inherited from Base

Base::AUTO_GENERATED_TAG_NAMES, Base::CONSIDERED_YARD_TAGS, Base::RUBY_CORE

Constants included from NodocHelper

NodocHelper::DOC_REGEX, NodocHelper::NO_DOC_ALL_REGEX, NodocHelper::NO_DOC_REGEX

Instance Attribute Summary

Attributes inherited from Base

#aliased_object_fullname, #api_tag, #base_dir, #object, #parent

Instance Method Summary collapse

Methods inherited from Base

#__parent, #api_tag?, #child, #children, #children_fullnames, #core?, #depth, #docstring, #filename, #files, #fullname, #has_children?, #has_multiple_code_examples?, #has_unconsidered_tags?, #in_in_root?, #in_root?, #initialize, #inspect, #name, #namespace?, #original_docstring, #private?, #protected?, #public?, #tagged_as_internal_api?, #tagged_as_private?, #unconsidered_tag_count, #undocumented?

Methods included from NodocHelper

#declarations, #explicit_doc_comment?, #explicit_nodoc_all_comment?, #explicit_nodoc_comment?, #get_line_no, #implicit_nodoc_all_comment?, #implicit_nodoc_comment?, #nodoc?, #nodoc_comment?

Constructor Details

This class inherits a constructor from Inch::CodeObject::Provider::YARD::Object::Base

Instance Method Details

#aliases_fullnamesObject



10
11
12
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 10

def aliases_fullnames
  object.aliases.map(&:path)
end

#bang_name?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 14

def bang_name?
  name =~ /\!$/
end

#constructor?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 18

def constructor?
  name == :initialize
end

#getter?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 22

def getter?
  attr_info = object.attr_info || {}
  read_info = attr_info[:read]
  if read_info
    read_info.path == fullname
  else
    parent.child(:"#{name}=")
  end
end

#has_code_example?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 32

def has_code_example?
  signatures.any? { |s| s.has_code_example? }
end

#has_doc?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 36

def has_doc?
  signatures.any? { |s| s.has_doc? }
end

#method?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 40

def method?
  true
end

#overridden?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 52

def overridden?
  !!object.overridden_method
end

#overridden_methodObject



56
57
58
59
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 56

def overridden_method
  return unless overridden?
  @overridden_method ||= YARD::Object.for(object.overridden_method)
end

#overridden_method_fullnameObject



61
62
63
64
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 61

def overridden_method_fullname
  return unless overridden?
  overridden_method.fullname
end

#parameter(name) ⇒ Object



48
49
50
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 48

def parameter(name)
  parameters.find { |p| p.name == name.to_s }
end

#parametersObject



44
45
46
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 44

def parameters
  @parameters ||= signatures.map(&:parameters).flatten
end

#questioning_name?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 100

def questioning_name?
  name =~ /\?$/
end

#return_described?Boolean

Returns true if a return value is described by words.

Returns:

  • (Boolean)


75
76
77
78
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 75

def return_described?
  return_described_via_tag? ||
    docstring.describes_return? && !implicit_docstring?
end

#return_mentioned?Boolean

Returns true if a return value is described by it’s type or mentioned in the docstring (e.g. “Returns a String”).

Returns:

  • (Boolean)


68
69
70
71
72
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 68

def return_mentioned?
  return_tags.any? do |t|
    !t.types.nil? && !t.types.empty? && !YARD.implicit_tag?(t, self)
  end || docstring.mentions_return? && !implicit_docstring?
end

#return_typed?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 80

def return_typed?
  return_mentioned?
end

#setter?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 84

def setter?
  name =~ /\=$/ && parameters.size == 1
end

#signaturesObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/inch/code_object/provider/yard/object/method_object.rb', line 88

def signatures
  base = MethodSignature.new(self, nil)
  overloaded = overload_tags.map do |tag|
    MethodSignature.new(self, tag)
  end
  if overloaded.any? { |s| s.same?(base) }
    overloaded
  else
    [base] + overloaded
  end
end