Sha256: 3e9cd46c3156b54a4ec421dd4e3788465ccc399f0828c0e45e7cbf5c18a4afa4

Contents?: true

Size: 390 Bytes

Versions: 3

Compression:

Stored size: 390 Bytes

Contents

module Shared
  class IOTerminal
    def present(prompt)
      print prompt
    end

    def present_with_new_line(prompt)
      puts prompt
    end

    def receive
      result = gets.chomp
      if is_int?(result)
        return result.to_i
      else
        return result.chomp
      end
    end

    private
    def is_int?(figure)
      Integer(figure) rescue false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
games_bfox-0.4.0 lib/games/shared/io_terminal.rb
games_bfox-0.3.0 lib/games/shared/io_terminal.rb
games_bfox-0.2.0 lib/games/shared/io_terminal.rb