Class: Javy::Platform

Inherits:
Struct
  • Object
show all
Defined in:
ext/javy/javy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ruby_platform = RUBY_PLATFORM) ⇒ Platform

Returns a new instance of Platform.



165
166
167
# File 'ext/javy/javy.rb', line 165

def initialize(ruby_platform = RUBY_PLATFORM)
  super(ruby_platform)
end

Instance Attribute Details

#ruby_platformObject

Returns the value of attribute ruby_platform

Returns:

  • (Object)

    the current value of ruby_platform



164
165
166
# File 'ext/javy/javy.rb', line 164

def ruby_platform
  @ruby_platform
end

Instance Method Details

#cpuObject



184
185
186
187
188
189
190
191
192
193
# File 'ext/javy/javy.rb', line 184

def cpu
  case ruby_platform
  when /x64/, /x86_64/
    "x86_64"
  when /arm/
    "arm"
  else
    raise InstallationError.cpu_unsupported
  end
end

#format_executable_path(path) ⇒ Object



195
196
197
198
199
200
201
202
# File 'ext/javy/javy.rb', line 195

def format_executable_path(path)
  case os
  when "windows"
    File.extname(path) != ".exe" ? path + ".exe" : path
  else
    path
  end
end

#osObject



173
174
175
176
177
178
179
180
181
182
# File 'ext/javy/javy.rb', line 173

def os
  case ruby_platform
  when /linux/
    "linux"
  when /darwin/
    "macos"
  else
    "windows"
  end
end

#to_sObject



169
170
171
# File 'ext/javy/javy.rb', line 169

def to_s
  format("%{cpu}-%{os}", cpu: cpu, os: os)
end