Sha256: 9029f7422ad36a3f4912432111fc735b50d6b84b9587515cc3acd9555ecc5e04
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
require 'singleton' require 'forwardable' module Exchange # Helper Functions that get used throughout the gem can be placed here # @author Beat Richartz # @version 0.6 # @since 0.3 # class Helper include Singleton extend SingleForwardable # A helper function to assure a value is an instance of time # @param [Time, String, NilClass] The value to be asserted # @param [Hash] opts Options for assertion # @option opts [Symbol] :default a method that can be sent to Time if the argument is nil (:now for example) # def assure_time(arg=nil, opts={}) if arg arg.kind_of?(Time) ? arg : Time.gm(*arg.split('-')) elsif opts[:default] Time.send(opts[:default]) end end # Forwards the assure_time method to the instance using singleforwardable # def_delegator :instance, :assure_time end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exchange-0.6.0 | lib/exchange/helper.rb |