Class: Enolib::Reporter
- Inherits:
-
Object
show all
- Defined in:
- lib/enolib/reporters/reporter.rb
Instance Method Summary
collapse
Constructor Details
#initialize(context) ⇒ Reporter
5
6
7
8
9
10
11
|
# File 'lib/enolib/reporters/reporter.rb', line 5
def initialize(context)
@context = context
@index = Array.new(@context.line_count)
@snippet = Array.new(@context.line_count)
build_index
end
|
Instance Method Details
#indicate_line(element) ⇒ Object
13
14
15
16
|
# File 'lib/enolib/reporters/reporter.rb', line 13
def indicate_line(element)
@snippet[element[:line]] = :indicate
self
end
|
#question_line(element) ⇒ Object
18
19
20
21
|
# File 'lib/enolib/reporters/reporter.rb', line 18
def question_line(element)
@snippet[element[:line]] = :question
self
end
|
23
24
25
26
27
28
29
30
|
# File 'lib/enolib/reporters/reporter.rb', line 23
def (element)
@snippet[element[:line]] = :indicate
element[:comments].each do ||
@snippet[[:line]] = :emphasize
end
self
end
|
#report_element(element) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/enolib/reporters/reporter.rb', line 32
def report_element(element)
@snippet[element[:line]] = :emphasize
tag_children(element, :indicate)
self
end
|
#report_elements(elements) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/enolib/reporters/reporter.rb', line 39
def report_elements(elements)
elements.each do |element|
@snippet[element[:line]] = :emphasize
tag_children(element, :indicate)
end
self
end
|
#report_line(instruction) ⇒ Object
48
49
50
51
52
|
# File 'lib/enolib/reporters/reporter.rb', line 48
def report_line(instruction)
@snippet[instruction[:line]] = :emphasize
self
end
|
#report_missing_element(parent) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/enolib/reporters/reporter.rb', line 62
def report_missing_element(parent)
@snippet[parent[:line]] = :indicate unless parent[:type] == :document
if parent[:type] == :section
tag_section(parent, :question, false)
else
tag_children(parent, :question)
end
self
end
|
#report_multiline_value(element) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/enolib/reporters/reporter.rb', line 54
def report_multiline_value(element)
element[:lines].each do |line|
@snippet[line[:line]] = :emphasize
end
self
end
|
#snippet ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/enolib/reporters/reporter.rb', line 74
def snippet
if @snippet.none?
(0...@snippet.length).each do |line|
@snippet[line] = :question
end
else
@snippet.each_with_index do |tag, line|
next if tag
if line + 2 < @context.line_count && @snippet[line + 2] && @snippet[line + 2] != :display ||
line - 2 > 0 && @snippet[line - 2] && @snippet[line - 2] != :display ||
line + 1 < @context.line_count && @snippet[line + 1] && @snippet[line + 1] != :display ||
line - 1 > 0 && @snippet[line - 1] && @snippet[line - 1] != :display
@snippet[line] = :display
elsif line + 3 < @context.line_count && @snippet[line + 3] && @snippet[line + 3] != :display
@snippet[line] = :omission
end
end
@snippet[-1] = :omission unless @snippet[-1]
end
print
end
|