Class: GetToWork::MenuPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/get_to_work/menu_presenter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MenuPresenter

Returns a new instance of MenuPresenter.



7
8
9
# File 'lib/get_to_work/menu_presenter.rb', line 7

def initialize(options)
  @options = options
end

Class Method Details

.with_collection(options) ⇒ Object



3
4
5
# File 'lib/get_to_work/menu_presenter.rb', line 3

def self.with_collection(options)
  new(options)
end

Instance Method Details

#item_for(choice:) ⇒ Object



17
18
19
20
# File 'lib/get_to_work/menu_presenter.rb', line 17

def item_for(choice:)
  index = choice.to_i - 1
  @options[index]
end


22
23
24
# File 'lib/get_to_work/menu_presenter.rb', line 22

def menu_limit
  (1..@options.count).map(&:to_s)
end

#tableObject



11
12
13
14
15
# File 'lib/get_to_work/menu_presenter.rb', line 11

def table
  @options.map.with_index do |option, i|
    [i + 1, option.name]
  end
end