Class: Minesweeper::Ui

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/minesweeper/ui.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.method_missing(method_name, *arguments, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/minesweeper/ui.rb', line 11

def self.method_missing(method_name, *arguments, &block)
  if instance.respond_to?(method_name)
    instance.send(method_name, *arguments, &block)
  else
    super
  end
end

.respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/minesweeper/ui.rb', line 19

def self.respond_to_missing?(method_name, include_private = false)
  instance.respond_to?(:method_name) || super
end

Instance Method Details

#col_numObject



51
52
53
# File 'lib/minesweeper/ui.rb', line 51

def col_num
  addstr('Number of columns: ')
end

#greeting_messageObject



37
38
39
40
41
42
43
44
45
# File 'lib/minesweeper/ui.rb', line 37

def greeting_message
  clear
  enable_keypad
  refresh
  addch("\n")
  addstr("Welcome to Minesweeper \n")
  addstr("screen size: rows: #{window.maxy}; columns: #{window.maxx / Minesweeper::Board::STEP} \n")
  addstr("controls: `space` to mark/unmark cell as bomb, `arrow keys` to navigate \n")
end

#levelObject



59
60
61
# File 'lib/minesweeper/ui.rb', line 59

def level
  addstr('Your Level (beginner/advanced/expert): ')
end

#params_messageObject



47
48
49
# File 'lib/minesweeper/ui.rb', line 47

def params_message
  addstr('Start game with default parameters? (Y/N)')
end

#row_numObject



55
56
57
# File 'lib/minesweeper/ui.rb', line 55

def row_num
  addstr('Number of rows: ')
end

#validation_errors(errors) ⇒ Object



63
64
65
66
67
68
# File 'lib/minesweeper/ui.rb', line 63

def validation_errors(errors)
  clear
  addstr("Some of the parameters were invalid \n")
  addstr(errors.full_messages.join("\n"))
  addstr("\n")
end

#windowObject



70
71
72
# File 'lib/minesweeper/ui.rb', line 70

def window
  @window ||= Window.new(0, 0, 0, 0)
end