class Array

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 41
def detach_from_parent(...)
  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 24
def to_alda_code
  contents = -> { map(&: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