class Hash

Contains patches to Ruby’s core classes.

Public Instance Methods

detach_from_parent(...) click to toggle source

See Alda::Event#detach_from_parent.

# File lib/alda-rb/patches.rb, line 74
def detach_from_parent(...)
  each.reverse_each { _1.detach_from_parent(...) }
end
to_alda_code() → String click to toggle source

See Alda::Event#to_alda_code. Behaves differently for Alda 1 and Alda 2 (due to a breaking change).

# File lib/alda-rb/patches.rb, line 57
def to_alda_code
  contents = -> { map { "#{_1.to_alda_code} #{_2.to_alda_code}" }.join ' ' }
  if Alda.v1?
    "{#{contents.()}}"
  else
    thread = Thread.current
    if thread.inside_alda_list
      "(#{contents.()})"
    else
      thread.inside_alda_list = true
      "'(#{contents.()})".tap { thread.inside_alda_list = false }
    end
  end
end