Class: AsciiDataTools::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii-data-tools/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#editorObject (readonly)

Returns the value of attribute editor.



7
8
9
# File 'lib/ascii-data-tools/configuration.rb', line 7

def editor
  @editor
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/ascii-data-tools/configuration.rb', line 7

def errors
  @errors
end

#input_sourcesObject (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_streamObject (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_typesObject (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_streamObject (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_usageObject



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

Returns:

  • (Boolean)


24
25
26
# File 'lib/ascii-data-tools/configuration.rb', line 24

def valid?
  @errors.empty?
end