Class: Inch::Evaluation::Grade

Inherits:
Object
  • Object
show all
Extended by:
Utils::ReadWriteMethods
Defined in:
lib/inch/evaluation/grade.rb

Overview

Grades are human-friendly representations of scores.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::ReadWriteMethods

rw_method, rw_methods

Constructor Details

#initialize(symbol) ⇒ Grade

Returns a new instance of Grade.



10
11
12
# File 'lib/inch/evaluation/grade.rb', line 10

def initialize(symbol)
  @symbol = symbol
end

Class Attribute Details

.grade_mapObject (readonly)

Returns the value of attribute grade_map.



33
34
35
# File 'lib/inch/evaluation/grade.rb', line 33

def grade_map
  @grade_map
end

Class Method Details

.allObject



35
36
37
38
# File 'lib/inch/evaluation/grade.rb', line 35

def all
  @grade_map ||= {}
  @grade_map.values
end

.grade(symbol, &block) ⇒ Object



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

def grade(symbol, &block)
  @grade_map ||= {}
  @grade_map[symbol] ||= Grade.new(symbol)
  @grade_map[symbol].update(&block) if block
  @grade_map[symbol]
end

Instance Method Details

#to_sString

Returns the grade as a string (e.g. “A”).

Returns:

  • (String)

    the grade as a string (e.g. “A”)



28
29
30
# File 'lib/inch/evaluation/grade.rb', line 28

def to_s
  @symbol.to_s
end

#to_symSymbol

Returns the grade as a symbol (e.g. :A).

Returns:

  • (Symbol)

    the grade as a symbol (e.g. :A)



23
24
25
# File 'lib/inch/evaluation/grade.rb', line 23

def to_sym
  @symbol
end

#update(&block) ⇒ void

This method returns an undefined value.

Updates the grade’s configuration with the given block

Parameters:

  • block (Proc)


18
19
20
# File 'lib/inch/evaluation/grade.rb', line 18

def update(&block)
  instance_eval(&block)
end