Class: Object

Inherits:
BasicObject
Defined in:
lib/music_coder.rb

Overview

These are the main methods in the API to be called from anywhere. Other important API classes to read are:

  • Dist

  • Snd

  • Note

  • HitSq

Instance Method Summary collapse

Instance Method Details

#deep_copyObject



17
18
19
# File 'lib/music_coder.rb', line 17

def deep_copy
  Marshal.load(Marshal.dump(self))
end

#init_hash(args) ⇒ Object

initialize all instance vars from a Hash if they are specified in args.



9
10
11
12
13
14
15
# File 'lib/music_coder.rb', line 9

def init_hash(args)
  instance_variables.each do |p|
    v_name = p[1,p.size]
    arg = args[v_name.to_sym] if not args.nil?
    self.instance_variable_set p, arg if not arg.nil?
  end
end

#vars_eql?(other, vars = nil) ⇒ Boolean

:nodoc: test if attributes are equal

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/music_coder.rb', line 21

def vars_eql?(other,vars=nil)
  vars ||= instance_variables
  vars.each do |var|
    # puts instance_variable_get(var)
    if instance_variable_get(var).respond_to? 'is_eql'
      # puts 'responds to is_eql'
      return false if !(instance_variable_get(var).is_eql other.instance_variable_get(var))
    else
      # puts "mine: #{instance_variable_get(var)} other: #{other.instance_variable_get(var)}"
      return false if !(instance_variable_get(var) == other.instance_variable_get(var))
    end
  end
  true
end