class Mongify::Mongoid::UI
Used to output messages to the UI
Public Class Methods
abort(message)
click to toggle source
Outputs a message and aborts execution of app
# File lib/mongify/mongoid/ui.rb, line 40 def abort(message) UI.puts "PROGRAM HALT: #{message}" Kernel.abort message end
ask(msg)
click to toggle source
Asks a yes or no question and waits for reply
# File lib/mongify/mongoid/ui.rb, line 30 def ask(msg) request("#{msg} [yn] ") == 'y' end
gets()
click to toggle source
Gets input from user
# File lib/mongify/mongoid/ui.rb, line 19 def gets in_stream ? in_stream.gets : '' end
in_stream()
click to toggle source
Incoming stream
# File lib/mongify/mongoid/ui.rb, line 46 def in_stream $stdin end
out_stream()
click to toggle source
Output stream
# File lib/mongify/mongoid/ui.rb, line 50 def out_stream $stdout end
print(msg)
click to toggle source
Outputs to stream using print method
# File lib/mongify/mongoid/ui.rb, line 14 def print(msg) out_stream.print(msg) if out_stream end
puts(msg)
click to toggle source
Outputs to stream using puts method
# File lib/mongify/mongoid/ui.rb, line 9 def puts(msg) out_stream.puts(msg) if out_stream end
request(msg)
click to toggle source
Outputs a question and gets input
# File lib/mongify/mongoid/ui.rb, line 24 def request(msg) print(msg) gets.chomp end
terminal_helper()
click to toggle source
Creates an instance of HighLine which lets us figure out width of console plus a whole lot more @return [HighLine] instance
# File lib/mongify/mongoid/ui.rb, line 58 def terminal_helper @terminal_helper ||= HighLine.new end
warn(msg)
click to toggle source
Outputs a Warning (using puts command)
# File lib/mongify/mongoid/ui.rb, line 35 def warn(msg) puts "WARNING: #{msg}" end