5
# Inline-level Element of document tree
6
class InlineElement < Element
10
class TerminalInline < InlineElement
11
include TerminalElement
13
attr_accessor :content
15
def initialize(content)
22
class NonterminalInline < InlineElement
23
include NonterminalElement
43
end # NonterminalInline
45
class StringElement < TerminalInline
47
visitor.visit_StringElement(self)
55
class Verb < TerminalInline
57
visitor.visit_Verb(self)
65
class Emphasis < NonterminalInline
67
visitor.visit_Emphasis(self)
71
class Code < NonterminalInline
73
visitor.visit_Code(self)
77
class Var < NonterminalInline
79
visitor.visit_Var(self)
83
class Keyboard < NonterminalInline
85
visitor.visit_Keyboard(self)
89
class Index < NonterminalInline
91
visitor.visit_Index(self)
95
class Footnote < NonterminalInline
97
visitor.visit_Footnote(self)
101
class Reference < NonterminalInline
102
attr_accessor :label # Reference::Label
103
alias set_label label=
105
def initialize(label)
108
@label = label.renew_label
111
def Reference.new_from_label(label)
112
ref = Reference.new(label)
113
ref.add_children(label.to_reference_content)
117
def Reference.new_from_label_under_document_struct(label, struct)
118
ref = Reference.new(label)
119
ref.add_children_under_document_struct(label.to_reference_content,
124
def Reference.new_from_label_without_document_struct(label)
125
ref = Reference.new(label)
126
ref.add_children_without_document_struct(label.to_reference_content)
131
visitor.visit_Reference(self)
134
def result_of_apply_method_of(visitor, children)
135
label.result_of_apply_method_of(visitor, self, children)
142
# abstruct class. Label for Reference
145
raise NotImplementedError, "[BUG] must be overridden."
148
def to_reference_content
149
raise NotImplementedError, "[BUG] must be overridden."
152
def result_of_apply_method_of(visitor)
153
raise NotImplementedError, "[BUG] must be overridden."
160
def initialize(url_str)
168
def result_of_apply_method_of(visitor, reference, children)
169
visitor.apply_to_Reference_with_URL(reference, children)
172
def to_reference_content
173
[StringElement.new("<URL:#{self.url}>")]
181
class RDLabel < Label
182
attr_accessor :element_label
183
attr_accessor :filename
185
def initialize(element_label, filename = nil)
186
@element_label = element_label
190
def result_of_apply_method_of(visitor, reference, children)
191
visitor.apply_to_Reference_with_RDLabel(reference, children)
194
def to_reference_content
202
alias to_label element_label
205
# for initialization. Parameter Object(?)
206
class TemporaryLabel < Label
207
attr_accessor :element_label
208
attr_accessor :filename
210
def initialize(element_label = [], filename = nil)
211
@element_label = element_label
215
def to_reference_content
220
RDLabel.new(extract_label(self.element_label), self.filename)
223
def extract_label(elements)
230
private :extract_label