Class: Mastermind::Main

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/mastermind/extensions/extensions.rb,
lib/mastermind/main.rb

Overview

module Helper

def get_input(message)
  # puts "Whatever it is"
  message
end

def send_message(message)

end

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#get_input, #send_message

Constructor Details

#initializeMain



6
7
8
# File 'lib/mastermind/main.rb', line 6

def initialize
  @response = Message.new
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



4
5
6
# File 'lib/mastermind/main.rb', line 4

def game
  @game
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/mastermind/main.rb', line 4

def response
  @response
end

Instance Method Details

#old_playObject



19
20
21
# File 'lib/mastermind/extensions/extensions.rb', line 19

def play
  @game.play
end

#playObject



30
31
32
# File 'lib/mastermind/main.rb', line 30

def play
  @game.play
end

#startObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/mastermind/main.rb', line 10

def start
  action = get_input(@response.start.message)
  if supported_actions.keys.include? action
    @game ||= Game.new(@response)
    method(supported_actions[action]).call
  else
    send_message @response.unsupported_game_action.message
  end
    start if supported_actions[action] =~ /instructions|background/ || @response.status == :unsupported_action
end