kelredd-useful 0.2.4 → 0.2.5

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.
@@ -1,7 +1,7 @@
1
1
  module Useful; end
2
2
  module Useful::RubyExtensions; end
3
3
 
4
- module Useful::RubyExtensions::Fixnum
4
+ module Useful::RubyExtensions::Integer
5
5
 
6
6
  # returns a string reprensentation of the number padded with pad_num to a specified length
7
7
  def pad(length = 3, pad_num = 0)
@@ -22,6 +22,12 @@ module Useful::RubyExtensions::Fixnum
22
22
  value
23
23
  end
24
24
 
25
+ # return a Time object for the given Integer
26
+ def to_time
27
+ Time.at(self)
28
+ end
29
+ alias_method :to_time_at, :to_time
30
+
25
31
  module FromActivesupport
26
32
  # All methods here will yield to their Activesupport versions, if defined
27
33
 
@@ -56,6 +62,6 @@ module Useful::RubyExtensions::Fixnum
56
62
 
57
63
  end
58
64
 
59
- class Fixnum
60
- include Useful::RubyExtensions::Fixnum
65
+ class Integer
66
+ include Useful::RubyExtensions::Integer
61
67
  end
@@ -1,6 +1,8 @@
1
1
  module Useful; end
2
2
  module Useful::RubyExtensions; end
3
3
 
4
+ require 'useful/ruby_extensions/integer' unless 1.respond_to?(:to_time_at)
5
+
4
6
  module Useful::RubyExtensions::String
5
7
 
6
8
  EMAIL_REGEXP = /\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
@@ -84,6 +86,10 @@ module Useful::RubyExtensions::String
84
86
  self.gsub(/[^0-9.-]/,'').to_f
85
87
  end
86
88
 
89
+ def to_time_at
90
+ self.to_i.to_time_at
91
+ end
92
+
87
93
  end
88
94
 
89
95
  module FromActivesupport
@@ -276,7 +282,7 @@ module Useful::RubyExtensions::String
276
282
  def to_date
277
283
  ::Date.civil(*::Date._parse(self, false).values_at(:year, :mon, :mday).map { |arg| arg || 0 }) rescue nil
278
284
  end unless "".respond_to?('to_date')
279
-
285
+
280
286
  end
281
287
 
282
288
  end
@@ -3,7 +3,7 @@ module Useful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 4
6
+ TINY = 5
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-23 00:00:00 -06:00
12
+ date: 2009-12-06 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -54,8 +54,8 @@ files:
54
54
  - lib/useful/ruby_extensions/array.rb
55
55
  - lib/useful/ruby_extensions/date.rb
56
56
  - lib/useful/ruby_extensions/false_class.rb
57
- - lib/useful/ruby_extensions/fixnum.rb
58
57
  - lib/useful/ruby_extensions/hash.rb
58
+ - lib/useful/ruby_extensions/integer.rb
59
59
  - lib/useful/ruby_extensions/nil_class.rb
60
60
  - lib/useful/ruby_extensions/numeric.rb
61
61
  - lib/useful/ruby_extensions/object.rb