Skip to content

Commit

Permalink
correct ounting
Browse files Browse the repository at this point in the history
  • Loading branch information
taf2 committed Apr 5, 2011
1 parent 619dbfb commit 3d9599b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Empty file modified bin/speech2text
100644 → 100755
Empty file.
29 changes: 24 additions & 5 deletions lib/speech/audio_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def to_s
end

def to_f
self.total_seconds
(self.hours.to_i * 3600) + (self.minutes.to_i * 60) + self.seconds.to_f
end

def self.from_seconds(seconds)
Expand All @@ -39,7 +39,8 @@ def self.from_seconds(seconds)
end

def +(b)
self.to_f + b.to_f
total = self.to_f + b.to_f
# puts "total: #{self.to_f} + #{b.to_f} = #{total.inspect}"
Duration.from_seconds(self.to_f + b.to_f)
end

Expand All @@ -61,17 +62,35 @@ def test_add_duration
a = Speech::AudioInspector::Duration.new("00:00:12.12")
b = Speech::AudioInspector::Duration.new("00:00:02.00")

assert "00:00:14.12", (a + b).to_s
assert_equal "00:00:14:12", (a + b).to_s

a = Speech::AudioInspector::Duration.new("00:10:12.12")
b = Speech::AudioInspector::Duration.new("08:00:02.00")

assert "08:10:14:12", (a + b).to_s
assert_equal "08:10:14:12", (a + b).to_s

a = Speech::AudioInspector::Duration.new("02:10:12.12")
b = Speech::AudioInspector::Duration.new("08:55:02.10")

assert "11:05:14:22", (a + b).to_s
assert_equal "11:05:14:22", (a + b).to_s

a = Speech::AudioInspector::Duration.new("00:00:12.12")
b = Speech::AudioInspector::Duration.new("00:00:02.00")

a = a + b
assert_equal "00:00:14:12", a.to_s
puts a.inspect

a = a + b
puts a.inspect

assert_equal "00:00:16:12", a.to_s

a = a + b
puts a.to_s
assert_equal "00:00:18:12", a.to_s
puts a.to_s
end

end
end
2 changes: 1 addition & 1 deletion lib/speech/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
module Speech
class Info
VERSION='0.3.3'
VERSION='0.3.4'
end
end

0 comments on commit 3d9599b

Please sign in to comment.