ruby-duration 0.1.5 → 0.1.6

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.5
1
+ 0.1.6
data/lib/duration.rb CHANGED
@@ -71,6 +71,14 @@ class Duration
71
71
  def iso8601
72
72
  format("P%wW%dDT%hH%mM%sS")
73
73
  end
74
+
75
+ def blank?
76
+ @total == 0
77
+ end
78
+
79
+ def present?
80
+ !blank?
81
+ end
74
82
 
75
83
  # Format a duration into a human-readable string.
76
84
  #
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-duration}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jose Peleteiro"]
@@ -37,5 +37,15 @@ class TestDuration < MiniTest::Unit::TestCase
37
37
  d = Duration.new(:weeks => 1, :days => 2, :hours => 3, :minutes => 4, :seconds => 5)
38
38
  assert_equal("P1W2DT3H4M5S", d.iso8601)
39
39
  end
40
+
41
+ def test_blank?
42
+ assert_true Duration.new.blank?
43
+ assert_false Duration.new(1).blank?
44
+ end
45
+
46
+ def test_present?
47
+ assert_false Duration.new.present?
48
+ assert_true Duration.new(1).present?
49
+ end
40
50
 
41
51
  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: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Peleteiro