Class: Lydown::Translation::Ripple::Root
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Lydown::Translation::Ripple::Root
show all
- Defined in:
- lib/lydown/translation/ripple/nodes.rb
Direct Known Subclasses
Barline, Command, FullRest, KeySignature, KeySignature::Mode, NamedMacro, NamedMacro::Stop, Noop, Note, Note::Articulation, Note::Duration, Note::Expression, Note::Grace, Note::Head, Phrasing, RelativeCommand, Repeat, Lydown::Translation::Ripple::Repeat::Alternative, Lydown::Translation::Ripple::Repeat::Start, TimeSignature
Instance Method Summary
collapse
Instance Method Details
#_translate(element, stream, opts) ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/lydown/translation/ripple/nodes.rb', line 3
def _translate(element, stream, opts)
if element.elements
element.elements.each do |e|
e.respond_to?(:translate) ?
e.translate(stream, opts) :
_translate(e, stream, opts)
end
end
stream
end
|
#check_line_break(stream, opts) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/lydown/translation/ripple/nodes.rb', line 28
def check_line_break(stream, opts)
line = source_line(opts)
if line != opts[:last_line]
unless stream.empty? || (stream[-1] == "\n")
stream.gsub!(/\s+$/, '')
stream << "\n"
end
opts[:last_line] = line
end
end
|
#source_line(opts) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/lydown/translation/ripple/nodes.rb', line 19
def source_line(opts)
if opts[:source]
line, column = opts[:source].find_line_and_column(interval.first)
line
else
nil
end
end
|
#translate(stream = [], opts = {}) ⇒ Object
14
15
16
17
|
# File 'lib/lydown/translation/ripple/nodes.rb', line 14
def translate(stream = [], opts = {})
_translate(self, stream, opts)
stream
end
|