Class: Plat4m::System

Inherits:
Object
  • Object
show all
Defined in:
lib/plat4m/system.rb

Overview

Instances of this class identify a system and provide access to system management support.

Defined Under Namespace

Classes: OS, Platform

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform, os) ⇒ System

Returns a new instance of System.



84
85
86
87
88
89
90
# File 'lib/plat4m/system.rb', line 84

def initialize(platform, os)
  unless platform && platform.complete? && os && os.complete?
    raise "Invalid system specification : #{os} @ #{platform}"
  end
  @platform = platform
  @os = os
end

Instance Attribute Details

#osObject (readonly)

Returns the value of attribute os.



92
93
94
# File 'lib/plat4m/system.rb', line 92

def os
  @os
end

#platformObject (readonly)

Returns the value of attribute platform.



92
93
94
# File 'lib/plat4m/system.rb', line 92

def platform
  @platform
end

Instance Method Details

#arm?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/plat4m/system.rb', line 102

def arm?
  @platform.arch =~ /arm/
end

#bitsObject



106
107
108
# File 'lib/plat4m/system.rb', line 106

def bits
  @platform.bits
end

#cpu_countObject



110
111
112
# File 'lib/plat4m/system.rb', line 110

def cpu_count
  @platform.cpus
end

#darwin?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/plat4m/system.rb', line 122

def darwin?
  @os.id == :darwin
end

#dev_nullObject



135
136
137
# File 'lib/plat4m/system.rb', line 135

def dev_null
  windows? ? 'NUL' : '/dev/null'
end

#freebsd?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/plat4m/system.rb', line 131

def freebsd?
  @os.id == :freebsd
end

#intel?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/plat4m/system.rb', line 98

def intel?
  @platform.arch =~ /x86/
end

#kindObject



94
95
96
# File 'lib/plat4m/system.rb', line 94

def kind
  "#{@platform.arch}-#{@os.id}"
end

#linux?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/plat4m/system.rb', line 114

def linux?
  @os.id == :linux
end

#macosx?Boolean Also known as: osx?

Returns:

  • (Boolean)


126
127
128
# File 'lib/plat4m/system.rb', line 126

def macosx?
  darwin? && @os.distro == 'MacOSX'
end

#windows?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/plat4m/system.rb', line 118

def windows?
  @os.id == :windows
end