Class: Inch::CodeObject::Proxy::MethodObject

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

Overview

Proxy class for methods

Constant Summary collapse

MANY_PARAMETERS_THRESHOLD =
3
MANY_LINES_THRESHOLD =
20

Constants inherited from Base

Base::CONSIDERED_YARD_TAGS

Constants included from NodocHelper

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

Instance Attribute Summary

Attributes inherited from Base

#grade, #object

Instance Method Summary collapse

Methods inherited from Base

#api_tag, #api_tag?, #children, #depth, #docstring, #evaluation, #filename, #has_alias?, #has_code_example?, #has_doc?, #has_multiple_code_examples?, #has_unconsidered_tags?, #in_root?, #initialize, #inspect, #namespace?, #parent, #private?, #private_api_tag?, #private_tag?, #protected?, #public?, #unconsidered_tags, #undocumented?

Methods included from NodocHelper

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

Constructor Details

This class inherits a constructor from Inch::CodeObject::Proxy::Base

Instance Method Details

#bang_name?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/inch/code_object/proxy/method_object.rb', line 15

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

#comment_and_abbrev_sourceObject



11
12
13
# File 'lib/inch/code_object/proxy/method_object.rb', line 11

def comment_and_abbrev_source
  comments.join('') + abbrev_source
end

#constructor?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/inch/code_object/proxy/method_object.rb', line 7

def constructor?
  name == :initialize
end

#has_many_lines?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
# File 'lib/inch/code_object/proxy/method_object.rb', line 29

def has_many_lines?
  # for now, this includes the 'def' line and comments
  if source = object.source
    size = source.lines.count
    size > MANY_LINES_THRESHOLD
  else
    false
  end
end

#has_many_parameters?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/inch/code_object/proxy/method_object.rb', line 24

def has_many_parameters?
  parameters.size > MANY_PARAMETERS_THRESHOLD
end

#has_parameters?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/inch/code_object/proxy/method_object.rb', line 19

def has_parameters?
  !parameters.empty?
end

#method?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/inch/code_object/proxy/method_object.rb', line 39

def method?
  true
end

#overridden?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/inch/code_object/proxy/method_object.rb', line 55

def overridden?
  !!object.overridden_method
end

#overridden_methodObject



59
60
61
# File 'lib/inch/code_object/proxy/method_object.rb', line 59

def overridden_method
  @overridden_method ||= Proxy.for(object.overridden_method)
end

#parameter(name) ⇒ Object



51
52
53
# File 'lib/inch/code_object/proxy/method_object.rb', line 51

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

#parametersObject



43
44
45
46
47
48
49
# File 'lib/inch/code_object/proxy/method_object.rb', line 43

def parameters
  @parameters ||= all_parameter_names.map do |name|
    in_signature = signature_parameter_names.include?(name)
    tag = parameter_tag(name)
    MethodParameterObject.new(self, name, tag, in_signature)
  end
end

#questioning_name?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/inch/code_object/proxy/method_object.rb', line 71

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

#return_described?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/inch/code_object/proxy/method_object.rb', line 67

def return_described?
  (return_tag && !return_tag.text.empty?) || docstring.describes_return?
end

#return_mentioned?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/inch/code_object/proxy/method_object.rb', line 63

def return_mentioned?
  !!return_tag || docstring.mentions_return?
end