Sha256: 108cc6978caa5310933733fde808239910da38b58af06c9511922f399fcc86b5

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

module Notifaction
  class Utils
    # Returns a formatted time string
    # Used, mainly, for printing timestamps next to terminal output
    # @since 0.0.1
    def self.formatted_time(time = nil)
      if time.nil?
        time = Time.now
      end

      time.strftime("%e/%-m/%Y @ %I:%M:%S%P")
    end

    # Determine the current OS
    # @since 0.0.1
    def self.os
      host_os = RbConfig::CONFIG['host_os']

      case host_os
      when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
        :windows
      when /darwin|mac os/
        :macosx
      when /linux/
        :linux
      when /solaris|bsd/
        :unix
      else
        puts "unknown os: #{host_os.inspect}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notifaction-0.4.4 lib/notifaction/utils.rb
notifaction-0.4.3 lib/notifaction/utils.rb
notifaction-0.4.2 lib/notifaction/utils.rb
notifaction-0.4.1 lib/notifaction/utils.rb