Sha256: 64e196384f596266ffd6e2431974e45be5c2787e9901fe8f9abe9a7697532314

Contents?: true

Size: 725 Bytes

Versions: 5

Compression:

Stored size: 725 Bytes

Contents

module Exchange
  # Helper Functions that get used throughout the gem can be placed here
  # @author Beat Richartz
  # @version 0.3
  # @since 0.3
  
  class Helper
    class << self
    
      # 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
    
    end
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
exchange-0.5.1 lib/exchange/helper.rb
exchange-0.4.4 lib/exchange/helper.rb
exchange-0.4.3 lib/exchange/helper.rb
exchange-0.4.1 lib/exchange/helper.rb
exchange-0.3.0 lib/exchange/helper.rb