Class: Lydown::Parsing::DurationValue

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

Constant Summary collapse

GRACE_KIND =
{
  '°' => :grace,
  '`' => :acciaccatura,
  '^' => :appoggiatura
}

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



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/lydown/parsing/nodes.rb', line 112

def to_stream(stream, opts)
  if text_value.strip =~ /^(.+)([°`^])$/
    event = {
      type: :grace,
      value: $1,
      kind: GRACE_KIND[$2]
    }
  else
    event = {
      type: :duration,
      value: text_value.strip
    }
    if event[:value] =~ /\!/
      event[:value].gsub!('!', '')
      event[:cross_bar_dotting] = true
    end
  end
  
  stream << event_hash(stream, opts, event)
end