Class: Inch::Evaluation::Proxy::Base Abstract

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/inch/evaluation/proxy/base.rb

Overview

This class is abstract.

Direct Known Subclasses

ConstantObject, MethodObject, NamespaceObject

Constant Summary collapse

MIN_SCORE =
0
MAX_SCORE =
100

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Base

Returns a new instance of Base.

Parameters:



38
39
40
41
42
# File 'lib/inch/evaluation/proxy/base.rb', line 38

def initialize(object)
  self.object = object
  @roles = []
  evaluate
end

Class Attribute Details

.criteria_mapObject (readonly)

Returns the value of attribute criteria_map.



15
16
17
# File 'lib/inch/evaluation/proxy/base.rb', line 15

def criteria_map
  @criteria_map
end

Instance Attribute Details

#objectCodeObject::Proxy::Base



12
13
14
# File 'lib/inch/evaluation/proxy/base.rb', line 12

def object
  @object
end

Class Method Details

.criteria(&block) ⇒ void

This method returns an undefined value.

Defines the weights during evaluation for different criteria

MethodObject.criteria do
  docstring           0.5
  parameters          0.4
  return_type         0.1

  if object.constructor?
    parameters        0.5
    return_type       0.0
  end
end


31
32
33
34
# File 'lib/inch/evaluation/proxy/base.rb', line 31

def criteria(&block)
  @criteria_map ||= {}
  @criteria_map[to_s] ||= ObjectSchema.new(&block)
end

Instance Method Details

#evaluateObject

Evaluates the objects and assigns roles



45
46
47
# File 'lib/inch/evaluation/proxy/base.rb', line 45

def evaluate
  __evaluate(object, relevant_roles)
end

#max_scoreFloat

Returns the max score that is assignable to object.

Returns:

  • (Float)

    the max score that is assignable to object



50
51
52
# File 'lib/inch/evaluation/proxy/base.rb', line 50

def max_score
  @__max_score = __max_score
end

#min_scoreFloat

Returns the min score that is assignable to object.

Returns:

  • (Float)

    the min score that is assignable to object



55
56
57
# File 'lib/inch/evaluation/proxy/base.rb', line 55

def min_score
  @__min_score = __min_score
end

#priorityFixnum

Returns the priority for object.

Returns:

  • (Fixnum)

    the priority for object



65
66
67
# File 'lib/inch/evaluation/proxy/base.rb', line 65

def priority
  @__priority ||= __priority
end

#rolesArray<Evaluation::Role::Base>

Returns:



70
71
72
# File 'lib/inch/evaluation/proxy/base.rb', line 70

def roles
  @roles
end

#scoreFixnum

Returns the final score for object.

Returns:

  • (Fixnum)

    the final score for object



60
61
62
# File 'lib/inch/evaluation/proxy/base.rb', line 60

def score
  @__score ||= __score
end