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:



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

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

Class Attribute Details

.criteria_mapObject (readonly)

Returns the value of attribute criteria_map.



17
18
19
# File 'lib/inch/evaluation/proxy/base.rb', line 17

def criteria_map
  @criteria_map
end

Instance Attribute Details

#max_scoreFloat (readonly)

Returns the max score that is assignable to object.

Returns:

  • (Float)

    the max score that is assignable to object



52
53
54
# File 'lib/inch/evaluation/proxy/base.rb', line 52

def max_score
  @max_score
end

#min_scoreFloat (readonly)

Returns the min score that is assignable to object.

Returns:

  • (Float)

    the min score that is assignable to object



57
58
59
# File 'lib/inch/evaluation/proxy/base.rb', line 57

def min_score
  @min_score
end

#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


33
34
35
36
# File 'lib/inch/evaluation/proxy/base.rb', line 33

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

Instance Method Details

#evaluateObject

Evaluates the objects and assigns roles



47
48
49
# File 'lib/inch/evaluation/proxy/base.rb', line 47

def evaluate
  __evaluate(object, relevant_roles)
end

#priorityFixnum

Returns the priority for object.

Returns:

  • (Fixnum)

    the priority for object



67
68
69
# File 'lib/inch/evaluation/proxy/base.rb', line 67

def priority
  @__priority ||= __priority
end

#rolesArray<Evaluation::Role::Base>

Returns:



72
73
74
# File 'lib/inch/evaluation/proxy/base.rb', line 72

def roles
  @roles
end

#scoreFloat

Returns the final score for object.

Returns:

  • (Float)

    the final score for object



62
63
64
# File 'lib/inch/evaluation/proxy/base.rb', line 62

def score
  @__score ||= __score
end