Class: Fitting::Doc::Code
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary
Attributes inherited from Step
#index_after, #index_before, #index_medium, #next_steps, #res_after, #res_before, #res_medium, #step_cover_size, #step_key
Instance Method Summary collapse
- #cover!(log) ⇒ Object
- #debug(debug) ⇒ Object
-
#initialize(code, value) ⇒ Code
constructor
A new instance of Code.
- #to_hash ⇒ Object
Methods inherited from Step
#index_offset, #mark_enum, #mark_range, #mark_required, #new_index_offset, #next, #nocover!, #range, #report, #valid?
Constructor Details
#initialize(code, value) ⇒ Code
Returns a new instance of Code.
9 10 11 12 13 14 15 16 17 |
# File 'lib/fitting/doc/code.rb', line 9 def initialize(code, value) @step_cover_size = 0 @step_key = code @next_steps = [] value.group_by { |val| val['content-type'] }.each do |content_type, subvalue| break if content_type == nil @next_steps.push(ContentType.new(content_type, subvalue)) end end |
Instance Method Details
#cover!(log) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/fitting/doc/code.rb', line 31 def cover!(log) if @step_key == log.status @step_cover_size += 1 @next_steps.each { |content_type| content_type.cover!(log) } end rescue Fitting::Doc::ContentType::NotFound => e raise NotFound.new "code: #{@step_key}\n\n"\ "#{e.}" end |
#debug(debug) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fitting/doc/code.rb', line 41 def debug(debug) if @step_key == debug.status @next_steps.each do |content_type| res = content_type.debug(debug) return res if res end nil end nil end |
#to_hash ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fitting/doc/code.rb', line 19 def to_hash if @next_steps.size == 1 && @next_steps[0].step_key == nil { @step_key => {} } else { @step_key => @next_steps.inject({}) { |sum, value| sum.merge!(value) } } end end |