Sha256: 4472ddc5908e6adf9d43f9d9452409c43c4a8a7421122f9627c2c0eedb199faf

Contents?: true

Size: 469 Bytes

Versions: 8

Compression:

Stored size: 469 Bytes

Contents

module SmsAero::Types
  # Describes coercible Unix time in future
  Future = Strict::Int.constructor do |value|
    begin
      error = TypeError.new "#{value.inspect} is not a valid time in future"

      time = value.to_time              if     value.respond_to? :to_time
      time ||= ::Time.parse(value.to_s) unless value.is_a? Numeric
      number = time.to_i

      number > ::Time.now.to_i ? number : raise(error)
    rescue
      raise error
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sms_aero-0.0.9 lib/sms_aero/types/future.rb
sms_aero-0.0.8 lib/sms_aero/types/future.rb
sms_aero-0.0.7 lib/sms_aero/types/future.rb
sms_aero-0.0.6 lib/sms_aero/types/future.rb
sms_aero-0.0.5 lib/sms_aero/types/future.rb
sms_aero-0.0.4 lib/sms_aero/types/future.rb
sms_aero-0.0.3 lib/sms_aero/types/future.rb
sms_aero-0.0.2 lib/sms_aero/types/future.rb