Module: Yasm::State::ClassMethods
- Defined in:
- lib/yasm/state.rb
Instance Method Summary collapse
- #actions(*allowed_actions) ⇒ Object
- #allowed_actions ⇒ Object
- #final! ⇒ Object
- #final? ⇒ Boolean
- #is_allowed?(action) ⇒ Boolean
- #maximum(maximum_duration, action_hash) ⇒ Object
- #maximum_duration ⇒ Object
- #maximum_duration_action ⇒ Object
- #minimum(time) ⇒ Object
- #minimum_duration ⇒ Object
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_actions ⇒ Object
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
25 26 27 |
# File 'lib/yasm/state.rb', line 25 def final? @allowed_actions == [] end |
#is_allowed?(action) ⇒ 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_duration ⇒ Object
47 48 49 |
# File 'lib/yasm/state.rb', line 47 def maximum_duration @maximum_duration end |
#maximum_duration_action ⇒ Object
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
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_duration ⇒ Object
38 39 40 |
# File 'lib/yasm/state.rb', line 38 def minimum_duration @state_minimum_duration end |