Class: FunWith::Passwords::CommandLineResult
- Inherits:
-
Object
- Object
- FunWith::Passwords::CommandLineResult
- Defined in:
- lib/fun_with/passwords/command_line_result.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
- #fail! ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(args) ⇒ CommandLineResult
constructor
A new instance of CommandLineResult.
- #puts(msg) ⇒ Object
- #puts_error(msg) ⇒ Object
- #stderr(msg) ⇒ Object
- #stdout(msg) ⇒ Object
- #succeed! ⇒ Object
- #success? ⇒ Boolean
- #verbose(verbosity = nil) ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ CommandLineResult
Returns a new instance of CommandLineResult.
6 7 8 9 10 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 6 def initialize( args ) @args = args @errors = [] @output = "" end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 4 def args @args end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 4 def errors @errors end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
4 5 6 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 4 def output @output end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
4 5 6 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 4 def success @success end |
Instance Method Details
#fail! ⇒ Object
30 31 32 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 30 def fail! @success = false end |
#failed? ⇒ Boolean
34 35 36 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 34 def failed? @success == false end |
#puts(msg) ⇒ Object
22 23 24 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 22 def puts( msg ) stdout( msg + "\n" ) end |
#puts_error(msg) ⇒ Object
26 27 28 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 26 def puts_error( msg ) stderr( msg + "\n" ) end |
#stderr(msg) ⇒ Object
12 13 14 15 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 12 def stderr( msg ) STDERR.puts( msg ) if @verbose @errors << msg end |
#stdout(msg) ⇒ Object
17 18 19 20 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 17 def stdout( msg ) STDOUT.write( msg ) if @verbose @output << msg end |
#succeed! ⇒ Object
38 39 40 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 38 def succeed! @success = true end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 42 def success? @success end |
#verbose(verbosity = nil) ⇒ Object
46 47 48 49 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 46 def verbose( verbosity = nil ) @verbose = !!verbosity unless verbosity.nil? @verbose end |
#verbose? ⇒ Boolean
51 52 53 |
# File 'lib/fun_with/passwords/command_line_result.rb', line 51 def verbose? end |