Permalink
Browse files

add nil parsing and move numeric and nil parsing to a common module

  • Loading branch information...
1 parent f610b68 commit 97a69e43586e02989bf608003943a291385c3080 S. Brent Faulkner committed Feb 21, 2010
Showing with 15 additions and 4 deletions.
  1. +1 −0 lib/elapsed_time.rb
  2. +0 −4 lib/elapsed_time/numeric.rb
  3. +14 −0 lib/elapsed_time/parse.rb
View
@@ -1,5 +1,6 @@
require 'elapsed_time/string'
require 'elapsed_time/numeric'
+require 'elapsed_time/parse'
require 'elapsed_time/validations'
require 'elapsed_time/helpers'
@@ -1,9 +1,5 @@
module ElapsedTime
module NumericMethods
- def parse_elapsed_time(options = {})
- self
- end
-
# Converts a numeric value representing a number of seconds to a string describing an elapsed time.
#
# 1234.to_elapsed_seconds
@@ -0,0 +1,14 @@
+module ElapsedTime
+ module DefaultParseMethods
+ def parse_elapsed_time(options = {})
+ self
+ end
+ alias_method :parse_elapsed_seconds, :parse_elapsed_time
+ alias_method :parse_elapsed_minutes, :parse_elapsed_time
+ alias_method :parse_elapsed_hours, :parse_elapsed_time
+ alias_method :parse_elapsed_days, :parse_elapsed_time
+ end
+end
+
+Integer.send :include, ElapsedTime::DefaultParseMethods
+NilClass.send :include, ElapsedTime::DefaultParseMethods

0 comments on commit 97a69e4

Please sign in to comment.