Class: AsciiDataTools::Configuration
- Inherits:
-
Object
- Object
- AsciiDataTools::Configuration
- Defined in:
- lib/ascii-data-tools/configuration.rb
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#input_sources ⇒ Object
readonly
Returns the value of attribute input_sources.
-
#output_stream ⇒ Object
readonly
Returns the value of attribute output_stream.
-
#record_types ⇒ Object
readonly
Returns the value of attribute record_types.
-
#user_feedback_stream ⇒ Object
readonly
Returns the value of attribute user_feedback_stream.
Instance Method Summary collapse
- #error_info_with_usage ⇒ Object
-
#initialize(arguments, overrides = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #valid? ⇒ Boolean
Constructor Details
#initialize(arguments, overrides = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ascii-data-tools/configuration.rb', line 9 def initialize(arguments, overrides = {}) @arguments = arguments @overrides = overrides @errors = [] @opts = define_optionparser_configuration remainder = parse(arguments) @output_stream = overrides[:output_stream] || STDOUT @input_sources = overrides[:input_sources] || make_input_streams(remainder, overrides) @record_types = overrides[:record_types] || load_record_types @editor = overrides[:editor] @user_feedback_stream = overrides[:user_feedback_stream] || STDOUT end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def editor @editor end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def errors @errors end |
#input_sources ⇒ Object (readonly)
Returns the value of attribute input_sources.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def input_sources @input_sources end |
#output_stream ⇒ Object (readonly)
Returns the value of attribute output_stream.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def output_stream @output_stream end |
#record_types ⇒ Object (readonly)
Returns the value of attribute record_types.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def record_types @record_types end |
#user_feedback_stream ⇒ Object (readonly)
Returns the value of attribute user_feedback_stream.
7 8 9 |
# File 'lib/ascii-data-tools/configuration.rb', line 7 def user_feedback_stream @user_feedback_stream end |
Instance Method Details
#error_info_with_usage ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ascii-data-tools/configuration.rb', line 28 def error_info_with_usage @errors.each {|error| puts error} puts puts @opts exit 1 end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/ascii-data-tools/configuration.rb', line 24 def valid? @errors.empty? end |