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

Instance Attribute Summary

Attributes inherited from Base

#grade, #object_lookup

Instance Method Summary collapse

Methods inherited from Base

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

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?
  self[:bang_name?]
end

#constructor?Boolean

Returns:

  • (Boolean)


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

def constructor?
  self[:constructor?]
end

#getter?Boolean

Returns:

  • (Boolean)


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

def getter?
  self[:getter?]
end

#has_many_lines?Boolean

Returns:

  • (Boolean)


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

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

Returns:

  • (Boolean)


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

def has_many_parameters?
  parameters.size > MANY_PARAMETERS_THRESHOLD
end

#has_parameters?Boolean

Returns:

  • (Boolean)


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

def has_parameters?
  !parameters.empty?
end

#overridden?Boolean

Returns:

  • (Boolean)


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

def overridden?
  self[:overridden?]
end

#overridden_methodObject



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

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

#parameter(name) ⇒ Object



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

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

#parametersObject



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

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

#questioning_name?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/inch/code_object/proxy/method_object.rb', line 76

def questioning_name?
  self[:questioning_name?]
end

#return_described?Boolean

Returns:

  • (Boolean)


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

def return_described?
  self[:return_described?]
end

#return_mentioned?Boolean

Returns:

  • (Boolean)


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

def return_mentioned?
  self[:return_mentioned?]
end

#return_typed?Boolean

Returns:

  • (Boolean)


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

def return_typed?
  self[:return_typed?]
end

#setter?Boolean

Returns:

  • (Boolean)


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

def setter?
  self[:setter?]
end

#sourceObject



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

def source
  self[:source?]
end