Class: Fission::UI
Instance Attribute Summary collapse
-
#stdout ⇒ Object
readonly
Internal: Returns the stdout value.
Instance Method Summary collapse
-
#initialize(stdout = $stdout) ⇒ UI
constructor
Internal: Initialize a UI object.
-
#output(s) ⇒ Object
Internal: Outputs the specified argument to the configured stdout object.
-
#output_and_exit(s, exit_code) ⇒ Object
Internal: Outputs the specified argument to the configured stdout object and exits with the specified exit code.
-
#output_printf(string, key, value) ⇒ Object
Internal: Outputs the specified arguments printf style.
Constructor Details
#initialize(stdout = $stdout) ⇒ UI
18 19 20 |
# File 'lib/fission/ui.rb', line 18 def initialize(stdout=$stdout) @stdout = stdout end |
Instance Attribute Details
#stdout ⇒ Object (readonly)
Internal: Returns the stdout value.
5 6 7 |
# File 'lib/fission/ui.rb', line 5 def stdout @stdout end |
Instance Method Details
#output(s) ⇒ Object
Internal: Outputs the specified argument to the configured stdout object. The ‘puts’ method will be called on the stdout object.
s - The String to output.
Examples
ui.output "foo bar\n"
Returns nothing.
32 33 34 |
# File 'lib/fission/ui.rb', line 32 def output(s) @stdout.puts s end |
#output_and_exit(s, exit_code) ⇒ Object
Internal: Outputs the specified argument to the configured stdout object and exits with the specified exit code.
s - The String to output. exit_code - The Integer exit code.
Examples
ui.output_and_exit 'something went wrong', 99
ui.output_and_exit 'all done', 0
Returns nothing.
66 67 68 69 |
# File 'lib/fission/ui.rb', line 66 def output_and_exit(s, exit_code) output s exit exit_code end |
#output_printf(string, key, value) ⇒ Object
Internal: Outputs the specified arguments printf style. The ‘printf’ method will be called on the stdout object. Currently, this assuems there are two data items.
string - The printf String. key - The String for the first data item. value - The String for the second data item.
Examples
ui.output_printf "%s %s\n", 'foo',
Returns nothing.
49 50 51 |
# File 'lib/fission/ui.rb', line 49 def output_printf(string, key, value) @stdout.send :printf, string, key, value end |