Sha256: d0aa8594ea3c7e953c3b53afa801a8d3545aa71a189d23b7da4e593888b6484c

Contents?: true

Size: 436 Bytes

Versions: 6

Compression:

Stored size: 436 Bytes

Contents

module GetToWork
  class MenuPresenter
    def self.with_collection(options)
      new(options)
    end

    def initialize(options)
      @options = options
    end

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
get_to_work-0.1.5 lib/get_to_work/menu_presenter.rb
get_to_work-0.1.4 lib/get_to_work/menu_presenter.rb
get_to_work-0.1.3 lib/get_to_work/menu_presenter.rb
get_to_work-0.1.2 lib/get_to_work/menu_presenter.rb
get_to_work-0.1.1 lib/get_to_work/menu_presenter.rb
get_to_work-0.1.0 lib/get_to_work/menu_presenter.rb