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

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

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?, #height, #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)


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

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

#comment_and_abbrev_sourceObject



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

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

#has_many_lines?Boolean

Returns:

  • (Boolean)


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

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)


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

def has_many_parameters?
  parameters.size > MANY_PARAMETERS_THRESHOLD
end

#has_parameters?Boolean

Returns:

  • (Boolean)


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

def has_parameters?
  !parameters.empty?
end

#method?Boolean

Returns:

  • (Boolean)


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

def method?
  true
end

#overridden?Boolean

Returns:

  • (Boolean)


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

def overridden?
  !!object.overridden_method
end

#overridden_methodObject



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

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

#parameter(name) ⇒ Object



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

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

#parametersObject



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

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

#return_mentioned?Boolean

Returns:

  • (Boolean)


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

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