Class: Music::Transcription::Change::Partial

Inherits:
Music::Transcription::Change show all
Defined in:
lib/music-transcription/model/change.rb

Instance Attribute Summary collapse

Attributes inherited from Music::Transcription::Change

#duration, #value

Instance Method Summary collapse

Methods inherited from Music::Transcription::Change

unpack

Constructor Details

#initialize(value, total_dur, elapsed, stop) ⇒ Partial

Returns a new instance of Partial.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/music-transcription/model/change.rb', line 52

def initialize value, total_dur, elapsed, stop
  if elapsed < 0
    raise NegativeError, "elapsed (#{elapsed}) is < 0"
  end
  
  if stop <= 0
    raise NonPositiveError, "stop (#{stop}) is < 0"
  end

  if stop > total_dur
    raise ArgumentError, "stop (#{stop}) is > total duration (#{total_dur})"
  end
  
  if stop <= elapsed
    raise ArgumentError, "stop (#{stop}) is <= elapsed (#{elapsed})"
  end

  @total_duration = total_dur
  @elapsed = elapsed
  @stop = stop
  super(value,stop - elapsed)
end

Instance Attribute Details

#elapsedObject (readonly)

Returns the value of attribute elapsed.



50
51
52
# File 'lib/music-transcription/model/change.rb', line 50

def elapsed
  @elapsed
end

#stopObject (readonly)

Returns the value of attribute stop.



50
51
52
# File 'lib/music-transcription/model/change.rb', line 50

def stop
  @stop
end

#total_durationObject (readonly)

Returns the value of attribute total_duration.



50
51
52
# File 'lib/music-transcription/model/change.rb', line 50

def total_duration
  @total_duration
end

Instance Method Details

#==(other) ⇒ Object



75
76
77
78
79
# File 'lib/music-transcription/model/change.rb', line 75

def ==(other)
  super() &&
  @elapsed == other.elapsed &&
  @stop == other.stop
end