lib/music-transcription/profile.rb in music-transcription-0.3.0 vs lib/music-transcription/profile.rb in music-transcription-0.4.0
- old
+ new
@@ -4,37 +4,29 @@
# Represent a setting that can change over time.
#
# @author James Tunnell
#
class Profile
- include Hashmake::HashMakeable
-
attr_accessor :start_value, :value_changes
-
- # hashed-arg specs (for hash-makeable idiom)
- ARG_SPECS = {
- :start_value => arg_spec(:reqd => true),
- :value_changes => arg_spec_hash(:reqd => false, :type => ValueChange)
- }
# A new instance of Profile.
#
# @param [Hash] args Hashed args. Required key is :start_value. Optional key is :value_changes.
- def initialize args
- hash_make args, Profile::ARG_SPECS
+ def initialize start_value, value_changes = {}
+ @start_value = start_value
+ @value_changes = value_changes
end
# Compare to another Profile object.
def == other
- (self.class == other.class) &&
(self.start_value == other.start_value) &&
(self.value_changes == other.value_changes)
end
# Produce an identical Profile object.
def clone
- Profile.new(:start_value => @start_value, :value_changes => @value_changes.clone)
+ Profile.new(@start_value, @value_changes.clone)
end
# Returns true if start value and value changes all are between given A and B.
def values_between? a, b
is_ok = self.start_value.between?(a,b)
@@ -58,11 +50,11 @@
end
return is_ok
end
def clone_and_collate computer_class, program_segments
- new_profile = Profile.new :start_value => start_value
+ new_profile = Profile.new start_value
segment_start_offset = 0.0
comp = computer_class.new(self)
program_segments.each do |seg|
@@ -90,16 +82,9 @@
segment_start_offset += (seg.last - seg.first)
end
return new_profile
end
-end
-
-module_function
-
-# Create a Profile object
-def profile start_value, value_changes = {}
- return Profile.new(:start_value => start_value, :value_changes => value_changes)
end
end
end