Class: Hatchet::OrCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/conditions.rb

Overview

Represents an OR group of conditions. The task proceeds when ANY condition is met.

Examples:

Wait for either a sleep or event

Hatchet.or_(
  Hatchet::SleepCondition.new(60),
  Hatchet::UserEventCondition.new(event_key: "start")
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*conditions) ⇒ OrCondition

Returns a new instance of OrCondition.

Parameters:

  • conditions (Array)

    Conditions to OR together



93
94
95
# File 'lib/hatchet/conditions.rb', line 93

def initialize(*conditions)
  @conditions = conditions
end

Instance Attribute Details

#conditionsArray (readonly)

Returns The conditions in this OR group.

Returns:

  • (Array)

    The conditions in this OR group



90
91
92
# File 'lib/hatchet/conditions.rb', line 90

def conditions
  @conditions
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


98
99
100
# File 'lib/hatchet/conditions.rb', line 98

def to_h
  { type: "or", conditions: @conditions.map(&:to_h) }
end