Class: I18nJSON::CLI::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n-json/cli/ui.rb

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:) ⇒ UI

Returns a new instance of UI.



6
7
8
9
# File 'lib/i18n-json/cli/ui.rb', line 6

def initialize(stdout:, stderr:)
  @stdout = stdout
  @stderr = stderr
end

Instance Method Details

#exit_with(*message) ⇒ Object



24
25
26
27
# File 'lib/i18n-json/cli/ui.rb', line 24

def exit_with(*message)
  stdout_print(message)
  exit(0)
end

#fail_with(*message) ⇒ Object



19
20
21
22
# File 'lib/i18n-json/cli/ui.rb', line 19

def fail_with(*message)
  stderr_print(message)
  exit(1)
end

#stderr_print(*message) ⇒ Object



15
16
17
# File 'lib/i18n-json/cli/ui.rb', line 15

def stderr_print(*message)
  @stderr << "#{message.join(' ')}\n"
end

#stdout_print(*message) ⇒ Object



11
12
13
# File 'lib/i18n-json/cli/ui.rb', line 11

def stdout_print(*message)
  @stdout << "#{message.join(' ')}\n"
end