Module: Yasm::State::ClassMethods

Defined in:
lib/yasm/state.rb

Instance Method Summary collapse

Instance Method Details

#actions(*allowed_actions) ⇒ Object



8
9
10
# File 'lib/yasm/state.rb', line 8

def actions(*allowed_actions)
  @allowed_actions = allowed_actions
end

#allowed_actionsObject



12
13
14
# File 'lib/yasm/state.rb', line 12

def allowed_actions
  @allowed_actions
end

#final!Object



21
22
23
# File 'lib/yasm/state.rb', line 21

def final!
  @allowed_actions = []
end

#final?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/yasm/state.rb', line 25

def final?
  @allowed_actions == []
end

#is_allowed?(action) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/yasm/state.rb', line 16

def is_allowed?(action)
  return true if @allowed_actions.nil?
  @allowed_actions.include? action.to_sym
end

#maximum(maximum_duration, action_hash) ⇒ Object



42
43
44
45
# File 'lib/yasm/state.rb', line 42

def maximum(maximum_duration, action_hash)
  @maximum_duration = maximum_duration
  @maximum_duration_action = action_hash[:action]
end

#maximum_durationObject



47
48
49
# File 'lib/yasm/state.rb', line 47

def maximum_duration
  @maximum_duration
end

#maximum_duration_actionObject



51
52
53
54
# File 'lib/yasm/state.rb', line 51

def maximum_duration_action
  return @maximum_duration_action.call if @maximum_duration_action.respond_to? :call
  @maximum_duration_action.to_class
end

#minimum(time) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
# File 'lib/yasm/state.rb', line 29

def minimum(time)
  raise(
    ArgumentError,
    "You must provide a Fixnum to the ##minimum method (represents number of seconds). For example: 2.minutes"
  ) unless time.kind_of?(Fixnum)

  @state_minimum_duration = time
end

#minimum_durationObject



38
39
40
# File 'lib/yasm/state.rb', line 38

def minimum_duration
  @state_minimum_duration
end