Class: Minesweeper::ParamsBuilder

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

Overview

used for reading / creating board params.

Constant Summary collapse

DEFAULTS =
{ height: 10, width: 10, level: 'advanced' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flush_params) ⇒ ParamsBuilder

Returns a new instance of ParamsBuilder.



12
13
14
15
# File 'lib/minesweeper/params_builder.rb', line 12

def initialize(flush_params)
  @flush_params = flush_params
  @ui = Minesweeper::Ui
end

Instance Attribute Details

#flush_paramsObject (readonly)

Returns the value of attribute flush_params.



10
11
12
# File 'lib/minesweeper/params_builder.rb', line 10

def flush_params
  @flush_params
end

#uiObject (readonly)

Returns the value of attribute ui.



10
11
12
# File 'lib/minesweeper/params_builder.rb', line 10

def ui
  @ui
end

Instance Method Details

#prepareObject



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

def prepare
  entry && entry.delete if flush_params
  entry || build
end