Class: Settlers::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/settlers/ui.rb

Instance Method Summary collapse

Constructor Details

#initializeUI

Returns a new instance of UI.



5
6
7
# File 'lib/settlers/ui.rb', line 5

def initialize
  @console = HighLine.new
end

Instance Method Details

#choose_server(list) {|case list.size when 0 abort 'No servers to choose from.' when 1 list.first else choose_from_many(list) end| ... } ⇒ Object

Yields:

  • (case list.size when 0 abort 'No servers to choose from.' when 1 list.first else choose_from_many(list) end)


9
10
11
12
13
14
15
16
17
18
# File 'lib/settlers/ui.rb', line 9

def choose_server(list)
  yield case list.size
        when 0
          abort 'No servers to choose from.'
        when 1
          list.first
        else
          choose_from_many(list)
        end
end