ruby-duration 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -6,9 +6,14 @@ class Duration
6
6
  total
7
7
  end
8
8
 
9
- def self.set(seconds)
10
- return Duration.new(0) unless seconds.respond_to?(:to_i)
11
- Duration.new(seconds.to_i)
9
+ def self.set(args)
10
+ if args.is_a?(Hash)
11
+ Duration.new(args)
12
+ elsif args.respond_to?(:to_i)
13
+ Duration.new(seconds.to_i)
14
+ else
15
+ Duration.new(0)
16
+ end
12
17
  end
13
18
  end
14
19
 
@@ -14,9 +14,13 @@ class Duration::TestMongoid < MiniTest::Unit::TestCase
14
14
  assert_equal zero, Duration.set(nil)
15
15
  end
16
16
 
17
- def test_set_default
17
+ def test_set_seconds
18
18
  assert_equal Duration.new(10), Duration.set("10")
19
19
  assert_equal Duration.new(10), Duration.set(10)
20
20
  end
21
21
 
22
+ def test_set_hash
23
+ assert_equal Duration.new(:minutes => 1, :seconds => 30), Duration.set(:minutes => 1, :seconds => 30)
24
+ end
25
+
22
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-duration
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Peleteiro