Class: Fitting::Doc::Step
- Inherits:
-
Object
- Object
- Fitting::Doc::Step
show all
- Defined in:
- lib/fitting/doc/step.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#index_after ⇒ Object
Returns the value of attribute index_after.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def index_after
@index_after
end
|
#index_before ⇒ Object
Returns the value of attribute index_before.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def index_before
@index_before
end
|
#index_medium ⇒ Object
Returns the value of attribute index_medium.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def index_medium
@index_medium
end
|
#next_steps ⇒ Object
Returns the value of attribute next_steps.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def next_steps
@next_steps
end
|
#res_after ⇒ Object
Returns the value of attribute res_after.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def res_after
@res_after
end
|
#res_before ⇒ Object
Returns the value of attribute res_before.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def res_before
@res_before
end
|
#res_medium ⇒ Object
Returns the value of attribute res_medium.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def res_medium
@res_medium
end
|
#step_cover_size ⇒ Object
Returns the value of attribute step_cover_size.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def step_cover_size
@step_cover_size
end
|
#step_key ⇒ Object
Returns the value of attribute step_key.
4
5
6
|
# File 'lib/fitting/doc/step.rb', line 4
def step_key
@step_key
end
|
Instance Method Details
#index_offset ⇒ Object
55
56
57
|
# File 'lib/fitting/doc/step.rb', line 55
def index_offset
YAML.dump(@next_steps.inject({}) { |sum, value| sum.merge!(value) }).split("\n").size
end
|
#mark_enum(index, res, schema) ⇒ Object
85
86
87
88
89
90
|
# File 'lib/fitting/doc/step.rb', line 85
def mark_enum(index, res, schema)
if schema["enum"].size == 1
res[index] = @step_cover_size
res[index + 1] = @step_cover_size
end
end
|
#mark_range(index, res) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/fitting/doc/step.rb', line 44
def mark_range(index, res)
res[index] = @step_cover_size
if @json_schema && @json_schema["required"]
mark_required(index, res, @json_schema)
end
end
|
#mark_required(index, res, schema) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/fitting/doc/step.rb', line 59
def mark_required(index, res, schema)
start_index = index + YAML.dump(schema["properties"]).split("\n").size
end_index = start_index + YAML.dump(schema["required"]).split("\n").size - 1
(start_index..end_index).each do |i|
res[i] = @step_cover_size
end
return if schema["required"].nil?
schema["required"].each do |required|
required_index = YAML.dump(schema["properties"]).split("\n").index { |key| key == "#{required}:" }
break if required_index.nil?
res[index + required_index] = @step_cover_size
res[index + required_index + 1] = @step_cover_size
res[index + required_index + 2] = @step_cover_size if schema["properties"][required]["type"] == "string" && schema["properties"][required]["enum"]
if schema["properties"][required]["type"] == "object"
res[index + required_index + 2] = @step_cover_size
new_index = index + required_index + 2
mark_required(new_index, res, schema["properties"][required])
elsif schema["properties"][required]["type"] == "string" && schema["properties"][required]["enum"]
new_index = index + required_index + 2
mark_enum(new_index, res, schema["properties"][required])
end
end
end
|
#new_index_offset ⇒ Object
51
52
53
|
# File 'lib/fitting/doc/step.rb', line 51
def new_index_offset
1
end
|
#next ⇒ Object
98
99
|
# File 'lib/fitting/doc/step.rb', line 98
def next
end
|
#nocover! ⇒ Object
12
13
14
15
16
17
|
# File 'lib/fitting/doc/step.rb', line 12
def nocover!
@step_cover_size = nil
@next_steps.each do |next_step|
next_step.nocover!
end
end
|
#range ⇒ Object
95
96
|
# File 'lib/fitting/doc/step.rb', line 95
def range
end
|
#report(res, index) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fitting/doc/step.rb', line 19
def report(res, index)
@index_before = index
@res_before = [] + res
mark_range(index, res)
@index_medium = index
@res_medium = [] + res
if @next_steps != []
new_index = index + new_index_offset
@next_steps.each do |next_step|
if self.class == Fitting::Doc::CombinationOneOf
res, _new_index = next_step.report(res, new_index - 2)
else
res, new_index = next_step.report(res, new_index)
end
end
end
index += index_offset
@index_after = index
@res_after = [] + res
[res, index]
end
|
#to_hash ⇒ Object
6
7
8
9
10
|
# File 'lib/fitting/doc/step.rb', line 6
def to_hash
{
@step_key => @next_steps.inject({}) { |sum, value| sum.merge!(value) }
}
end
|
#valid? ⇒ Boolean
92
93
|
# File 'lib/fitting/doc/step.rb', line 92
def valid?
end
|