Class: SeeingIsBelieving::Binary

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing/binary.rb,
lib/seeing_is_believing/binary/arg_parser.rb,
lib/seeing_is_believing/binary/line_formatter.rb,
lib/seeing_is_believing/binary/print_results_next_to_lines.rb

Defined Under Namespace

Classes: ArgParser, LineFormatter, PrintResultsNextToLines

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin, stdout, stderr) ⇒ Binary

Returns a new instance of Binary.



10
11
12
13
14
15
# File 'lib/seeing_is_believing/binary.rb', line 10

def initialize(argv, stdin, stdout, stderr)
  self.argv   = argv
  self.stdin  = stdin
  self.stdout = stdout
  self.stderr = stderr
end

Instance Attribute Details

#argvObject

Returns the value of attribute argv.



8
9
10
# File 'lib/seeing_is_believing/binary.rb', line 8

def argv
  @argv
end

#stderrObject

Returns the value of attribute stderr.



8
9
10
# File 'lib/seeing_is_believing/binary.rb', line 8

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



8
9
10
# File 'lib/seeing_is_believing/binary.rb', line 8

def stdin
  @stdin
end

#stdoutObject

Returns the value of attribute stdout.



8
9
10
# File 'lib/seeing_is_believing/binary.rb', line 8

def stdout
  @stdout
end

Instance Method Details

#callObject Also known as: exitstatus



17
18
19
20
21
22
23
24
25
# File 'lib/seeing_is_believing/binary.rb', line 17

def call
  @exitstatus ||= if    flags_have_errors?          then print_errors          ; 1
                  elsif should_print_help?          then print_help            ; 0
                  elsif has_filename? && file_dne?  then print_file_dne        ; 1
                  elsif should_clean?               then print_cleaned_program ; 0
                  elsif invalid_syntax?             then print_syntax_error    ; 1
                  else                                   print_program         ; (results.has_exception? ? 1 : 0)
                  end
end