Class: Rip::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/rip/ui.rb

Instance Method Summary collapse

Constructor Details

#initialize(io = nil, verbose = false) ⇒ UI

Returns a new instance of UI.



3
4
5
6
# File 'lib/rip/ui.rb', line 3

def initialize(io = nil, verbose = false)
  @io = io
  @verbose = verbose
end

Instance Method Details

#abort(msg) ⇒ Object



21
22
23
# File 'lib/rip/ui.rb', line 21

def abort(msg)
  @io && Kernel.abort("rip: #{msg}")
end

#puts(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rip/ui.rb', line 8

def puts(*args)
  return unless @io

  if args.empty?
    @io.puts ""
  else
    args.each { |msg| @io.puts(msg) }
  end

  @io.flush
  nil
end

#vputs(*args) ⇒ Object



25
26
27
# File 'lib/rip/ui.rb', line 25

def vputs(*args)
  puts(*args) if @verbose
end