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

#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_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)


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

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

#comment_and_abbrev_sourceObject



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

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

#has_many_lines?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'lib/inch/code_object/proxy/method_object.rb', line 24

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)


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

def has_many_parameters?
  parameters.size > MANY_PARAMETERS_THRESHOLD
end

#has_parameters?Boolean

Returns:

  • (Boolean)


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

def has_parameters?
  !parameters.empty?
end

#method?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/inch/code_object/proxy/method_object.rb', line 34

def method?
  true
end

#overridden?Boolean

Returns:

  • (Boolean)


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

def overridden?
  !!object.overridden_method
end

#overridden_methodObject



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

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

#parameter(name) ⇒ Object



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

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

#parametersObject



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

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)


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

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

#return_described?Boolean

Returns:

  • (Boolean)


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

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

#return_mentioned?Boolean

Returns:

  • (Boolean)


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

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