Class: FunWith::Passwords::CommandLineResult

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_with/passwords/command_line_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject (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

#errorsObject (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

#outputObject (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

#successObject (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


51
52
53
# File 'lib/fun_with/passwords/command_line_result.rb', line 51

def verbose?
  
end