Class: Brackets::Util::BooleanCounter
- Inherits:
-
Object
- Object
- Brackets::Util::BooleanCounter
- Defined in:
- lib/brackets/util/boolean_counter.rb
Instance Method Summary collapse
-
#initialize ⇒ BooleanCounter
constructor
A new instance of BooleanCounter.
- #next_if(boolean, falsey_value = nil) ⇒ Object
Constructor Details
#initialize ⇒ BooleanCounter
Returns a new instance of BooleanCounter.
4 5 6 |
# File 'lib/brackets/util/boolean_counter.rb', line 4 def initialize @counter = 0 end |
Instance Method Details
#next_if(boolean, falsey_value = nil) ⇒ Object
8 9 10 |
# File 'lib/brackets/util/boolean_counter.rb', line 8 def next_if(boolean, falsey_value = nil) boolean ? @counter += 1 : falsey_value || @counter end |