Class: Lydown::Parsing::TupletValue

Inherits:
Root
  • Object
show all
Defined in:
lib/lydown/parsing/nodes.rb

Instance Method Summary collapse

Methods inherited from Root

#initialize

Methods included from RootMethods

#_to_stream, #add_event, #each_child, #event_hash

Constructor Details

This class inherits a constructor from Lydown::Parsing::Root

Instance Method Details

#to_stream(stream, opts) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/lydown/parsing/nodes.rb', line 135

def to_stream(stream, opts)
  if text_value =~ /^(\d+)%((\d+)\/(\d+))?$/
    value, fraction, group_length = $1, $2, $4
    unless fraction
      fraction = '3/2'
      group_length = '2'
    end

    stream << event_hash(stream, opts, {
      type: :tuplet_duration,
      value: value,
      fraction: fraction,
      group_length: group_length
    })
  end
end