countdownobj 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 Daniel P. Clark & 6ft Dan(TM)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
data/README ADDED
File without changes
@@ -0,0 +1,49 @@
1
+ # CountDownObj - Count Down Object
2
+ # by Daniel P. Clark
3
+ # The MIT License
4
+
5
+ class CountDownObj
6
+ @@second = 1
7
+ @@minute = @@second * 60
8
+ @@hour = @@minute * 60
9
+ @@day = @@hour * 24
10
+ @@week = @@day * 7
11
+
12
+ attr_accessor :countdownto
13
+
14
+ def initialize(countdownto = (Time.now + @@day))
15
+ self.countdownto = countdownto
16
+ end
17
+
18
+ def deadline
19
+ self.countdownto - Time.at(Time.now.to_f)
20
+ end
21
+
22
+ def to_s
23
+ out = ""
24
+ val = []
25
+ [[@@week, "week"], [@@day, "day"], [@@hour, "hour"], [@@minute, "minute"], [@@second, "second"]].each do |tm|
26
+ if val.empty?
27
+ val = deadline.divmod(tm[0])
28
+ else
29
+ val = val[1].divmod(tm[0])
30
+ end
31
+ if val[0] > 0
32
+ out << "#{val[0]} "
33
+ if val[0] > 1
34
+ out << "#{tm[1]}s"
35
+ else
36
+ out << "#{tm[1]}"
37
+ end
38
+ if not tm[1] == "second"
39
+ out << ", "
40
+ end
41
+ end
42
+ end
43
+ out.chomp(", ")
44
+ end
45
+
46
+ def deadline=(timeObject)
47
+ self.countdownto = Time.at(timeObject)
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ class CountDownObj
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: countdownobj
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Daniel P. Clark / 6ftDan(TM)
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-12-04 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: An object base on Time that'll let you know how much time is left until the deadline. Count Down Object
22
+ email: webmaster@6ftdan.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ files:
30
+ - lib/countdownobj/version.rb
31
+ - lib/countdownobj.rb
32
+ - README
33
+ - LICENSE
34
+ homepage: http://www.github.com/danielpclark/CountDownObj
35
+ licenses:
36
+ - The MIT License (MIT)
37
+ post_install_message: Counting Down 3.. 2.. 1.. Enjoy!
38
+ rdoc_options:
39
+ - --main
40
+ - README
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.24
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: An object base on Time that'll let you know how much time is left until the deadline.
68
+ test_files: []
69
+