Class: Tabletop::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/tabletop/condition.rb

Overview

Stores a block to evaluate against a Pool

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Condition

Returns a new instance of Condition.



5
6
7
# File 'lib/tabletop/condition.rb', line 5

def initialize(&block)
  @test = block
end

Instance Method Details

#met_by?(pool) ⇒ Boolean

returns false if the stored block evaluates to false or nil, otherwise returns true

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/tabletop/condition.rb', line 11

def met_by?(pool)
  if @test.call(pool)
    true
  else
    false
  end
end