Class: Randsum::ReplacerTarget
- Inherits:
-
Object
- Object
- Randsum::ReplacerTarget
- Defined in:
- lib/randsum/filters/replacers/replacer_targets/replacer_target.rb
Direct Known Subclasses
Constant Summary collapse
- ALL =
:all
Instance Attribute Summary collapse
-
#roll ⇒ Object
readonly
Returns the value of attribute roll.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target, roll:) ⇒ ReplacerTarget
constructor
A new instance of ReplacerTarget.
- #match ⇒ Object
Constructor Details
#initialize(target, roll:) ⇒ ReplacerTarget
Returns a new instance of ReplacerTarget.
17 18 19 20 |
# File 'lib/randsum/filters/replacers/replacer_targets/replacer_target.rb', line 17 def initialize(target, roll:) @target = target @roll = roll end |
Instance Attribute Details
#roll ⇒ Object (readonly)
Returns the value of attribute roll.
4 5 6 |
# File 'lib/randsum/filters/replacers/replacer_targets/replacer_target.rb', line 4 def roll @roll end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/randsum/filters/replacers/replacer_targets/replacer_target.rb', line 4 def target @target end |
Class Method Details
.for(target, roll:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/randsum/filters/replacers/replacer_targets/replacer_target.rb', line 6 def self.for(target, roll:) case target when ALL ReplacerTargetAll when nil ReplacerTargetAll else ReplacerTarget end.new(target, roll: roll) end |
Instance Method Details
#match ⇒ Object
22 23 24 25 26 |
# File 'lib/randsum/filters/replacers/replacer_targets/replacer_target.rb', line 22 def match roll.result.select do |r| r == target end end |