Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/alda-rb/patches.rb

Overview

Contains patches to Ruby’s core classes.

Instance Method Summary collapse

Instance Method Details

#detach_from_parentObject

See Alda::Event#detach_from_parent.



41
42
43
# File 'lib/alda-rb/patches.rb', line 41

def detach_from_parent(...)
  reverse_each { _1.detach_from_parent(...) }
end

#to_alda_codeObject

:call-seq:

to_alda_code() -> String

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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