Class: Anodator::OutputSpec
- Inherits:
-
Object
- Object
- Anodator::OutputSpec
- Defined in:
- lib/anodator/output_spec.rb
Constant Summary collapse
- TARGET_DATA =
"DATA"
- TARGET_ERROR =
"ERROR"
- VALID_SYMBOL_ITEMS =
[ :target_numbers, :target_names, :target_values, :error_message, :error_level, :error_count, :warning_count, :error_and_warning_count, ]
Instance Attribute Summary collapse
-
#include_no_error ⇒ Object
readonly
Returns the value of attribute include_no_error.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#value_separator ⇒ Object
Returns the value of attribute value_separator.
Instance Method Summary collapse
- #generate(input_spec_with_values, check_results) ⇒ Object
-
#initialize(items = [], options = { }) ⇒ OutputSpec
constructor
A new instance of OutputSpec.
- #validate_configuration ⇒ Object
Constructor Details
#initialize(items = [], options = { }) ⇒ OutputSpec
Returns a new instance of OutputSpec.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/anodator/output_spec.rb', line 20 def initialize(items = [], = { }) @items = items.to_a @target = TARGET_ERROR @include_no_error = false @separator = " " @value_separator = "" .each do |key, opt| case key when :target @target = opt when :include_no_error @include_no_error = !!opt when :separator, :value_separator @separator = opt.to_s else raise ArgumentError.new("unknown option #{key}.") end end unless [TARGET_DATA, TARGET_ERROR].include?(@target) raise ArgumentError.new("unknown target option value #{@target}.") end check_items end |
Instance Attribute Details
#include_no_error ⇒ Object (readonly)
Returns the value of attribute include_no_error.
17 18 19 |
# File 'lib/anodator/output_spec.rb', line 17 def include_no_error @include_no_error end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
17 18 19 |
# File 'lib/anodator/output_spec.rb', line 17 def items @items end |
#separator ⇒ Object
Returns the value of attribute separator.
18 19 20 |
# File 'lib/anodator/output_spec.rb', line 18 def separator @separator end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
17 18 19 |
# File 'lib/anodator/output_spec.rb', line 17 def target @target end |
#value_separator ⇒ Object
Returns the value of attribute value_separator.
18 19 20 |
# File 'lib/anodator/output_spec.rb', line 18 def value_separator @value_separator end |
Instance Method Details
#generate(input_spec_with_values, check_results) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/anodator/output_spec.rb', line 68 def generate(input_spec_with_values, check_results) if @target == TARGET_DATA generate_data(input_spec_with_values, check_results) else # @target == TARGET_ERROR generate_error(input_spec_with_values, check_results) end end |
#validate_configuration ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/anodator/output_spec.rb', line 47 def validate_configuration @items.each do |item| if item.is_a? String Validator::Base.values.spec_item_at_by_number(item) end end rescue UnknownTargetExpressionError => e raise InvalidConfiguration.new(e.to_s) end |