Class: Notifaction::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/notifaction/utils.rb

Class Method Summary collapse

Class Method Details

.formatted_time(time = nil) ⇒ Object

Returns a formatted time string Used, mainly, for printing timestamps next to terminal output

Since:

  • 0.0.1



6
7
8
9
10
11
12
# File 'lib/notifaction/utils.rb', line 6

def self.formatted_time(time = nil)
  if time.nil?
    time = Time.now
  end

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

.osObject

Determine the current OS

Since:

  • 0.0.1



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/notifaction/utils.rb', line 16

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