class Subtt::Duration

Attributes

ms[RW]

Public Class Methods

new(other) click to toggle source
# File lib/subtt/duration.rb, line 6
def initialize(other)
  set other
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/subtt/duration.rb, line 33
def <=>(other)
  @ms <=> other.ms
end
coerce(other) click to toggle source
# File lib/subtt/duration.rb, line 10
def coerce(other)
  return Duration.new(other), self
end
set(other) click to toggle source
# File lib/subtt/duration.rb, line 14
def set(other)
  @ms = other

  @hours = (other / 3600000).to_i
  other -= @hours * 3600000

  @minutes = (other / 60000).to_i
  other -= @minutes * 60000

  @seconds = (other / 1000).to_i
  other -= @seconds * 1000

  @miliseconds = other
end
to_s() click to toggle source
# File lib/subtt/duration.rb, line 29
def to_s
  "%02d:%02d:%02d,%03d" % [@hours, @minutes, @seconds, @miliseconds]
end