Class: SeeingIsBelieving::Binary
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary
- Defined in:
- lib/seeing_is_believing/binary.rb,
lib/seeing_is_believing/binary/align_file.rb,
lib/seeing_is_believing/binary/align_line.rb,
lib/seeing_is_believing/binary/arg_parser.rb,
lib/seeing_is_believing/binary/align_chunk.rb,
lib/seeing_is_believing/binary/line_formatter.rb,
lib/seeing_is_believing/binary/add_annotations.rb,
lib/seeing_is_believing/binary/remove_previous_annotations.rb
Defined Under Namespace
Classes: AddAnnotations, AlignChunk, AlignFile, AlignLine, ArgParser, LineFormatter, RemovePreviousAnnotations
Constant Summary collapse
- SUCCESS_STATUS =
0
- DISPLAYABLE_ERROR_STATUS =
e.g. there was an error, but the output is legit (we can display exceptions)
1
- NONDISPLAYABLE_ERROR_STATUS =
e.g. an error like incorrect invocation or syntax that can’t be displayed in the input program
2
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
-
#timeout_error ⇒ Object
Returns the value of attribute timeout_error.
-
#unexpected_exception ⇒ Object
Returns the value of attribute unexpected_exception.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv, stdin, stdout, stderr) ⇒ Binary
constructor
A new instance of Binary.
Constructor Details
#initialize(argv, stdin, stdout, stderr) ⇒ Binary
Returns a new instance of Binary.
16 17 18 19 20 21 |
# File 'lib/seeing_is_believing/binary.rb', line 16 def initialize(argv, stdin, stdout, stderr) self.argv = argv self.stdin = stdin self.stdout = stdout self.stderr = stderr end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def argv @argv end |
#stderr ⇒ Object
Returns the value of attribute stderr.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def stdout @stdout end |
#timeout_error ⇒ Object
Returns the value of attribute timeout_error.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def timeout_error @timeout_error end |
#unexpected_exception ⇒ Object
Returns the value of attribute unexpected_exception.
14 15 16 |
# File 'lib/seeing_is_believing/binary.rb', line 14 def unexpected_exception @unexpected_exception end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/seeing_is_believing/binary.rb', line 23 def call @exitstatus ||= begin parse_flags if flags_have_errors? then print_errors ; NONDISPLAYABLE_ERROR_STATUS elsif should_print_help? then print_help ; SUCCESS_STATUS elsif should_print_version? then print_version ; SUCCESS_STATUS elsif has_filename? && file_dne? then print_file_dne ; NONDISPLAYABLE_ERROR_STATUS elsif should_clean? then print_cleaned_program ; SUCCESS_STATUS elsif invalid_syntax? then print_syntax_error ; NONDISPLAYABLE_ERROR_STATUS elsif (evaluate_program; program_timedout?) then print_timeout_error ; NONDISPLAYABLE_ERROR_STATUS elsif something_blew_up? then print_unexpected_error ; NONDISPLAYABLE_ERROR_STATUS else print_program ; program_exit_status end end end |