Class: AcpcPokerMatchState::MatchStateTransition

Inherits:
Object
  • Object
show all
Defined in:
lib/acpc_poker_match_state/match_state_transition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_stateObject (readonly)

Returns the value of attribute last_state.



11
12
13
# File 'lib/acpc_poker_match_state/match_state_transition.rb', line 11

def last_state
  @last_state
end

#next_stateObject (readonly)

Returns the value of attribute next_state.



10
11
12
# File 'lib/acpc_poker_match_state/match_state_transition.rb', line 10

def next_state
  @next_state
end

Instance Method Details

#initial_state?Boolean

Returns:

  • (Boolean)

Raises:

  • (NoStateGiven)


28
29
30
31
32
# File 'lib/acpc_poker_match_state/match_state_transition.rb', line 28

def initial_state?
  raise NoStateGiven unless @next_state

  @next_state.first_state_of_first_round?
end

#new_round?Boolean

Returns true if the next state’s round is different from the last, false otherwise.

Returns:

  • (Boolean)

    true if the next state’s round is different from the last, false otherwise.

Raises:

  • (NoStateGiven)


21
22
23
24
25
26
# File 'lib/acpc_poker_match_state/match_state_transition.rb', line 21

def new_round?
  raise NoStateGiven unless @next_state
  return true unless @last_state

  @next_state.round != @last_state.round
end

#set_next_state!(new_state) ⇒ Object



13
14
15
16
17
# File 'lib/acpc_poker_match_state/match_state_transition.rb', line 13

def set_next_state!(new_state)
  @last_state = @next_state
  @next_state = new_state
  self
end