Class: Scorecard::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/scorecard/rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRules

Returns a new instance of Rules.



4
5
6
# File 'lib/scorecard/rules.rb', line 4

def initialize
  @point_rules = []
end

Instance Attribute Details

#point_rulesObject (readonly)

Returns the value of attribute point_rules.



2
3
4
# File 'lib/scorecard/rules.rb', line 2

def point_rules
  @point_rules
end

Instance Method Details

#add(context, amount, options = {}) ⇒ Object



8
9
10
# File 'lib/scorecard/rules.rb', line 8

def add(context, amount, options = {})
  point_rules << Scorecard::PointRule.new(context, amount, options)
end

#clearObject



16
17
18
# File 'lib/scorecard/rules.rb', line 16

def clear
  point_rules.clear
end

#find(context) ⇒ Object



12
13
14
# File 'lib/scorecard/rules.rb', line 12

def find(context)
  point_rules.detect { |rule| rule.context == context }
end