Class: Minesweeper::Ui
- Inherits:
-
Object
- Object
- Minesweeper::Ui
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/minesweeper/ui.rb
Class Method Summary collapse
- .method_missing(method_name, *arguments, &block) ⇒ Object
- .respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Instance Method Summary collapse
- #col_num ⇒ Object
- #greeting_message ⇒ Object
- #level ⇒ Object
- #params_message ⇒ Object
- #row_num ⇒ Object
- #validation_errors(errors) ⇒ Object
- #window ⇒ Object
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
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_num ⇒ Object
51 52 53 |
# File 'lib/minesweeper/ui.rb', line 51 def col_num addstr('Number of columns: ') end |
#greeting_message ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/minesweeper/ui.rb', line 37 def 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 |
#level ⇒ Object
59 60 61 |
# File 'lib/minesweeper/ui.rb', line 59 def level addstr('Your Level (beginner/advanced/expert): ') end |
#params_message ⇒ Object
47 48 49 |
# File 'lib/minesweeper/ui.rb', line 47 def addstr('Start game with default parameters? (Y/N)') end |
#row_num ⇒ Object
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..join("\n")) addstr("\n") end |
#window ⇒ Object
70 71 72 |
# File 'lib/minesweeper/ui.rb', line 70 def window @window ||= Window.new(0, 0, 0, 0) end |