sugarcube 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -0
- data/lib/sugarcube/numeric.rb +20 -0
- data/lib/sugarcube/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -326,6 +326,18 @@ end
|
|
326
326
|
1.second.every do
|
327
327
|
@view.shake
|
328
328
|
end
|
329
|
+
|
330
|
+
# other time-related methods
|
331
|
+
1.second || 2.seconds
|
332
|
+
1.minute || 2.minutes # 60 seconds
|
333
|
+
1.hour || 2.hours # 60 minutes
|
334
|
+
1.day || 2.days # 24 hours
|
335
|
+
1.week || 2.weeks # 7 days
|
336
|
+
# with sensible values for 'month' and 'year', even though we all know you can't
|
337
|
+
# **really** define them this way (go back to python if you find your brain
|
338
|
+
# hemorrhaging):
|
339
|
+
1.month || 2.months # 30 days
|
340
|
+
1.year || 2.years # 365 days
|
329
341
|
```
|
330
342
|
|
331
343
|
NSUserDefaults
|
data/lib/sugarcube/numeric.rb
CHANGED
@@ -19,6 +19,26 @@ class Numeric
|
|
19
19
|
end
|
20
20
|
alias :hour :hours
|
21
21
|
|
22
|
+
def days
|
23
|
+
self.hours * 24
|
24
|
+
end
|
25
|
+
alias :day :days
|
26
|
+
|
27
|
+
def weeks
|
28
|
+
self.days * 7
|
29
|
+
end
|
30
|
+
alias :week :weeks
|
31
|
+
|
32
|
+
def months
|
33
|
+
self.days * 30
|
34
|
+
end
|
35
|
+
alias :month :months
|
36
|
+
|
37
|
+
def years
|
38
|
+
self.days * 365
|
39
|
+
end
|
40
|
+
alias :year :years
|
41
|
+
|
22
42
|
def later(user_info=nil, &fire)
|
23
43
|
NSTimer.scheduledTimerWithTimeInterval(self.to_f, target: fire, selector: 'call:', userInfo: user_info, repeats: false)
|
24
44
|
end
|
data/lib/sugarcube/version.rb
CHANGED