Class: Inch::Language::Ruby::CodeObject::MethodObject

Inherits:
Base show all
Defined in:
lib/inch/language/ruby/code_object/method_object.rb

Overview

Proxy class for methods

Constant Summary collapse

MANY_PARAMETERS_THRESHOLD =
3
MANY_LINES_THRESHOLD =
20

Instance Attribute Summary

Attributes inherited from CodeObject::Proxy

#object_lookup

Instance Method Summary collapse

Methods inherited from Base

#alias?, #aliased_object, #api_tag?, #children, #constant?, #core?, #depth, #docstring, #filename, #files, #fullname, #has_alias?, #has_children?, #has_code_example?, #has_doc?, #has_multiple_code_examples?, #has_unconsidered_tags?, #in_root?, #language, #method?, #name, #namespace?, #nodoc?, #original_docstring, #parent, #private?, #protected?, #public?, #tagged_as_internal_api?, #tagged_as_private?, #type, #unconsidered_tag_count, #undocumented?, #visibility

Methods inherited from CodeObject::Proxy

#[], for, #initialize, #inspect, #language, #marshal_dump, #marshal_load

Constructor Details

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

Instance Method Details

#bang_name?Boolean



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

def bang_name?
  self[:bang_name?]
end

#constructor?Boolean



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

def constructor?
  self[:constructor?]
end

#getter?Boolean



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

def getter?
  self[:getter?]
end

#has_many_lines?Boolean



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

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

#has_many_parameters?Boolean



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

def has_many_parameters?
  parameters.size > MANY_PARAMETERS_THRESHOLD
end

#has_parameters?Boolean



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

def has_parameters?
  !parameters.empty?
end

#overridden?Boolean



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

def overridden?
  self[:overridden?]
end

#overridden_methodObject



53
54
55
56
# File 'lib/inch/language/ruby/code_object/method_object.rb', line 53

def overridden_method
  @overridden_method ||=
    object_lookup.find(self[:overridden_method_fullname])
end

#parameter(name) ⇒ Object



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

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

#parametersObject



43
44
45
46
47
# File 'lib/inch/language/ruby/code_object/method_object.rb', line 43

def parameters
  @parameters ||= self[:parameters].map do |param_attr|
    MethodParameterObject.new(param_attr)
  end
end

#questioning_name?Boolean



78
79
80
# File 'lib/inch/language/ruby/code_object/method_object.rb', line 78

def questioning_name?
  self[:questioning_name?]
end

#return_described?Boolean



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

def return_described?
  self[:return_described?]
end

#return_mentioned?Boolean



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

def return_mentioned?
  self[:return_mentioned?]
end

#return_typed?Boolean



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

def return_typed?
  self[:return_typed?]
end

#setter?Boolean



70
71
72
# File 'lib/inch/language/ruby/code_object/method_object.rb', line 70

def setter?
  self[:setter?]
end

#sourceObject



74
75
76
# File 'lib/inch/language/ruby/code_object/method_object.rb', line 74

def source
  self[:source?]
end