Class: Librarian::UI::Shell

Inherits:
Librarian::UI show all
Defined in:
lib/librarian/ui.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ Shell

Returns a new instance of Shell


24
25
26
27
28
29
# File 'lib/librarian/ui.rb', line 24

def initialize(shell)
  @shell = shell
  @quiet = false
  @debug = ENV['DEBUG']
  @debug_line_numbers = false
end

Instance Attribute Details

#debug_line_numbersObject (readonly)

Returns the value of attribute debug_line_numbers


22
23
24
# File 'lib/librarian/ui.rb', line 22

def debug_line_numbers
  @debug_line_numbers
end

#shell=(value) ⇒ Object (writeonly)

Sets the attribute shell

Parameters:

  • value

    the value to set the attribute shell to.


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

def shell=(value)
  @shell = value
end

Instance Method Details

#be_quiet!Object


51
52
53
# File 'lib/librarian/ui.rb', line 51

def be_quiet!
  @quiet = true
end

#confirm(message = nil) ⇒ Object


39
40
41
# File 'lib/librarian/ui.rb', line 39

def confirm(message = nil)
  @shell.say(message || yield, :green) if !@quiet
end

#debug(message = nil) ⇒ Object


31
32
33
# File 'lib/librarian/ui.rb', line 31

def debug(message = nil)
  @shell.say(message || yield) if @debug && !@quiet
end

#debug!Object


55
56
57
# File 'lib/librarian/ui.rb', line 55

def debug!
  @debug = true
end

#debug_line_numbers!Object


59
60
61
# File 'lib/librarian/ui.rb', line 59

def debug_line_numbers!
  @debug_line_numbers = true
end

#error(message = nil) ⇒ Object


47
48
49
# File 'lib/librarian/ui.rb', line 47

def error(message = nil)
  @shell.say(message || yield, :red)
end

#info(message = nil) ⇒ Object


35
36
37
# File 'lib/librarian/ui.rb', line 35

def info(message = nil)
  @shell.say(message || yield) if !@quiet
end

#warn(message = nil) ⇒ Object


43
44
45
# File 'lib/librarian/ui.rb', line 43

def warn(message = nil)
  @shell.say(message || yield, :yellow)
end