From 32ae377ec00b2d4840b70b6001fc5a2821106d0c Mon Sep 17 00:00:00 2001 From: kn1kn1 Date: Tue, 12 Sep 2017 21:27:35 +0900 Subject: [PATCH] :art: --- petal.rb | 1 - petal_data.rb | 6 +++--- petal_parser.rb | 16 ++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/petal.rb b/petal.rb index c7c256e..0ed4211 100644 --- a/petal.rb +++ b/petal.rb @@ -35,7 +35,6 @@ module PetalLang module Petal - extend self include PetalLang::LoopHolder @@seconds_per_cycle = 1.0 diff --git a/petal_data.rb b/petal_data.rb index da6656e..badc75d 100644 --- a/petal_data.rb +++ b/petal_data.rb @@ -25,7 +25,7 @@ def initialize(bpm, sound_array, stretch = nil, random_n = nil, random_gain = ni def ==(other) return false if other.nil? - return false unless other.is_a?(Cycle) + return false unless other.instance_of?(Cycle) @bpm == other.bpm && @sound_array == other.sound_array && @stretch == other.stretch && @random_n == other.random_n && @random_gain == other.random_gain && @random_pan == other.random_pan && @@ -52,7 +52,7 @@ def initialize(sample_name, index, divisor) def ==(other) return false if other.nil? - return false unless other.is_a?(Sound) + return false unless other.instance_of?(Sound) @name == other.name && @index == other.index && @divisor.to_f == other.divisor.to_f && @amp.to_f == other.amp.to_f && @pan.to_f == other.pan.to_f && @rate.to_f == other.rate.to_f @@ -72,7 +72,7 @@ def initialize(value, divisor) def ==(other) return false if other.nil? - return false unless other.is_a?(Option) + return false unless other.instance_of?(Option) @value == other.value && @divisor.to_f == other.divisor.to_f end diff --git a/petal_parser.rb b/petal_parser.rb index 8c13e5b..21eaf9f 100644 --- a/petal_parser.rb +++ b/petal_parser.rb @@ -39,7 +39,7 @@ def find_element(index_array, target_array) def dfs_merge_with_n_array(sound_array, n_array) dfs_each_with_index_map(sound_array) do |sound, index_array| n_element = find_element(index_array, n_array) - sound.index = n_element.value.to_i unless n_element == Option::REST + sound.index = n_element.value.to_i unless Option::REST.equal?(n_element) sound end end @@ -47,7 +47,7 @@ def dfs_merge_with_n_array(sound_array, n_array) def dfs_merge_with_gain_array(sound_array, gain_array) dfs_each_with_index_map(sound_array) do |sound, index_array| gain = find_element(index_array, gain_array) - sound.amp = gain.value unless gain == Option::REST + sound.amp = gain.value unless Option::REST.equal?(gain) sound end end @@ -55,7 +55,7 @@ def dfs_merge_with_gain_array(sound_array, gain_array) def dfs_merge_with_pan_array(sound_array, pan_array) dfs_each_with_index_map(sound_array) do |sound, index_array| pan = find_element(index_array, pan_array) - sound.pan = pan.value unless pan == Option::REST + sound.pan = pan.value unless Option::REST.equal?(pan) sound end end @@ -63,14 +63,14 @@ def dfs_merge_with_pan_array(sound_array, pan_array) def dfs_merge_with_speed_array(sound_array, speed_array) dfs_each_with_index_map(sound_array) do |sound, index_array| speed = find_element(index_array, speed_array) - sound.rate = sound.rate.to_f * speed.value.to_f unless speed == Option::REST + sound.rate = sound.rate.to_f * speed.value.to_f unless Option::REST.equal?(speed) sound end end def dfs_merge_n_array_with_sound_array(n_array, sound_array) dfs_each_with_index_map(n_array) do |n_element, index_array| - if n_element == Option::REST + if Option::REST.equal?(n_element) sound = Sound::REST else s = find_element(index_array, sound_array) @@ -83,7 +83,7 @@ def dfs_merge_n_array_with_sound_array(n_array, sound_array) def dfs_merge_gain_array_with_sound_array(gain_array, sound_array) dfs_each_with_index_map(gain_array) do |gain, index_array| - if gain == Option::REST + if Option::REST.equal?(gain) sound = Sound::REST else s = find_element(index_array, sound_array) @@ -96,7 +96,7 @@ def dfs_merge_gain_array_with_sound_array(gain_array, sound_array) def dfs_merge_pan_array_with_sound_array(pan_array, sound_array) dfs_each_with_index_map(pan_array) do |pan, index_array| - if pan == Option::REST + if Option::REST.equal?(pan) sound = Sound::REST else s = find_element(index_array, sound_array) @@ -109,7 +109,7 @@ def dfs_merge_pan_array_with_sound_array(pan_array, sound_array) def dfs_merge_speed_array_with_sound_array(speed_array, sound_array) dfs_each_with_index_map(speed_array) do |speed, index_array| - if speed == Option::REST + if Option::REST.equal?(speed) sound = Sound::REST else s = find_element(index_array, sound_array)