lib/ensurance/time_ensure.rb in ensurance-0.1.11 vs lib/ensurance/time_ensure.rb in ensurance-0.1.12
- old
+ new
@@ -9,19 +9,19 @@
end
module ClassMethods
def ensure(thing)
case thing.class.name
- when "NilClass"
+ when 'NilClass'
thing
- when "Time"
+ when 'Time'
thing
- when "Date"
+ when 'Date'
thing.beginning_of_day
- when "Integer", "Float"
+ when 'Integer', 'Float'
::Time.at(thing)
- when "String"
+ when 'String'
if thing.to_i.to_s == thing
::Time.at(thing.to_i)
elsif thing.to_f.to_s == thing
::Time.at(thing.to_f)
else
@@ -29,25 +29,22 @@
end
else
if thing.respond_to?(:to_time)
thing.to_time
else
- raise ArgumentError.new("Unhandled Type for Time to ensure: #{thing.class}")
+ raise ArgumentError, "Unhandled Type for Time to ensure: #{thing.class}"
end
end
end
- def ensure!(thing)
+ def ensure!(_thing)
def ensure!(thing)
result = self.ensure(thing)
raise ArgumentError, "Cannot Time.ensure(#{thing})" unless result
result
end
end
-
end
-
end
end
::Time.prepend(Ensurance::TimeEnsure)
-