Class: Commons::Lang::SystemUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/commons/lang/system_utils.rb

Constant Summary collapse

@@current_platform =
nil
@@line_separator =
nil
@@file_separator =
nil
@@path_separator =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSystemUtils

Returns a new instance of SystemUtils.



48
49
50
# File 'lib/commons/lang/system_utils.rb', line 48

def initialize
  super()
end

Class Method Details

.current_platformObject



53
54
55
56
57
58
59
# File 'lib/commons/lang/system_utils.rb', line 53

def self.current_platform
  if @@current_platform == nil
    @@current_platform = System.current_platform
  end
  
  return @@current_platform
end

.file_separatorObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/commons/lang/system_utils.rb', line 75

def self.file_separator
  if @@file_separator == nil
    if File::ALT_SEPARATOR == nil
      @@file_separator = File::SEPARATOR
    else
      @@file_separator = File::ALT_SEPARATOR
    end
=begin
    if os_windows?
      @@file_separator = '\\'
    else
      @@file_separator = '/'
    end
=end
  end
  
  return @@file_separator
end

.line_separatorObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/commons/lang/system_utils.rb', line 62

def self.line_separator
  if @@line_separator == nil
    if os_windows?
      @@line_separator = "\r\n"
    else
      @@line_separator = "\n"
    end
  end
  
  return @@line_separator
end

.os_windows?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/commons/lang/system_utils.rb', line 104

def self.os_windows?
  return current_platform.include?('mswin32')
end

.path_separatorObject



95
96
97
98
99
100
101
# File 'lib/commons/lang/system_utils.rb', line 95

def self.path_separator
  if @@path_separator == nil
    @@path_separator = File::PATH_SEPARATOR
  end
  
  return @@path_separator
end