Class: Music::Transcription::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/music-transcription/model/change.rb,
lib/music-transcription/packing/change_packing.rb

Direct Known Subclasses

Gradual, Immediate, Partial

Defined Under Namespace

Classes: Gradual, Immediate, Partial

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, duration) ⇒ Change

Returns a new instance of Change.



7
8
9
10
# File 'lib/music-transcription/model/change.rb', line 7

def initialize value, duration
  @value = value
  @duration = duration
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



5
6
7
# File 'lib/music-transcription/model/change.rb', line 5

def duration
  @duration
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/music-transcription/model/change.rb', line 5

def value
  @value
end

Class Method Details

.unpack(packing) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/music-transcription/packing/change_packing.rb', line 17

def self.unpack packing
  case packing.size
  when 1 then Immediate.new(*packing)
  when 2 then Gradual.new(*packing)
  else raise ArgumentError, "bad array size"
  end
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
15
16
# File 'lib/music-transcription/model/change.rb', line 12

def ==(other)
  self.class == other.class &&
  self.value == other.value &&
  self.duration == other.duration
end