Module: Lydown::Parsing::Root
- Included in:
- Chord, Command, DurationMacroExpression, DurationValue, GraceDuration, Lyrics, Note, Rest, Setting, Silence, SourceRef, StandAloneFigures, TupletValue
- Defined in:
- lib/lydown/parsing/nodes.rb
Instance Method Summary collapse
- #_to_stream(element, stream, opts) ⇒ Object
- #event_hash(stream, opts, hash = {}) ⇒ Object
- #to_stream(stream = [], opts = {}) ⇒ Object
Instance Method Details
#_to_stream(element, stream, opts) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/lydown/parsing/nodes.rb', line 3 def _to_stream(element, stream, opts) if element.elements element.elements.each do |e| e.respond_to?(:to_stream) ? e.to_stream(stream, opts) : _to_stream(e, stream, opts) end end stream end |
#event_hash(stream, opts, hash = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lydown/parsing/nodes.rb', line 19 def event_hash(stream, opts, hash = {}) if source = opts[:source] last = stream.last if last && last[:type] == :source_ref && last[:line] line, column = last[:line], last[:column] else line, column = source.find_line_and_column(interval.first) end hash.merge({ filename: opts[:filename], source: source, line: line, column: column }) else hash end end |
#to_stream(stream = [], opts = {}) ⇒ Object
14 15 16 17 |
# File 'lib/lydown/parsing/nodes.rb', line 14 def to_stream(stream = [], opts = {}) _to_stream(self, stream, opts) stream end |