Class: Cyclotone::MiniNotation::AST::Node
- Inherits:
-
Object
- Object
- Cyclotone::MiniNotation::AST::Node
show all
- Defined in:
- lib/cyclotone/mini_notation/ast.rb
Direct Known Subclasses
Alternating, Atom, Choice, Degrade, Elongate, Euclidean, Polymetric, Repeat, Replicate, Rest, Sequence, Slow, Stack
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.deep_freeze(value) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/cyclotone/mini_notation/ast.rb', line 7
def self.deep_freeze(value)
case value
when Array
value.map { |entry| deep_freeze(entry) }.freeze
when Hash
value.each_with_object({}) do |(key, entry), frozen_hash|
frozen_hash[deep_freeze(key)] = deep_freeze(entry)
end.freeze
else
value.freeze
end
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
20
21
22
|
# File 'lib/cyclotone/mini_notation/ast.rb', line 20
def ==(other)
other.is_a?(self.class) && to_h == other.to_h
end
|
#hash ⇒ Object
26
27
28
|
# File 'lib/cyclotone/mini_notation/ast.rb', line 26
def hash
[self.class, to_h].hash
end
|
#to_mn ⇒ Object
30
31
32
|
# File 'lib/cyclotone/mini_notation/ast.rb', line 30
def to_mn
AST.to_source(self)
end
|