Sha256: 34d1516bf90b249c5b45ab941e4f35dd53d38d35e1264f9f574a094712420fcb

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

module TorrentSearch
  module Views

    class Menu < Base
      def initialize(actions, search_result)
        @actions = actions
        @search_result = search_result
      end

      def display
        say_status "\n[Results]", '', :green
        if results?
          print_search_result_table
        else
          say 'Nothing found'
        end
        say_status "\n[Actions]", action_menu, :blue
      end

    private
      def results?
        @search_result.any?
      end

      def print_search_result_table
        print_table ResultTable.new(@search_result)
      end

      def action_menu
        @actions.map {|hash| hash.join(": ")}.join("\t")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
torrent_search-0.0.3 lib/torrent_search/views/menu.rb
torrent_search-0.0.2 lib/torrent_search/views/menu.rb