Find out what's your file's architecture using Ruby!
#4
Well... guess I'd have to provide an answer. Tongue sticking out

For those thinking that RUBY_PLATFORM would do the trick, nope. It falters when Java is in use, returning 'Java' even if the PC itself was Windows, Mac or Linux. So I had to dig further.

The main consensus is the use of RbConfig. Unfortunately, RPGMaker XP (or any) do not come supplied with it, and there are various versions as there are various versions of Ruby. But after examining various versions of RbConfig from versions 1.8.5 through to more modern 2., I determined that I had need of only a handful of lines.

Below is a scriptette that can determine what Operating System your PC is using, returning something like :windows, :linux, :unix or :macosx.

Code:
#==============================================================================
# ** OS Detection via Ruby
#------------------------------------------------------------------------------
#    by DerVVulfman (09/08/2019) MM/DD/YYYY
#    based on the work of Thomas Enebo (11/27/2012) MM/DD/YYYY
#==============================================================================



#==============================================================================
# ** RbConfig
#------------------------------------------------------------------------------
#  This module holds Configuration settings for Ruby Operations.
#  THIS IS NOT COMPLETE, BUT A BAREBONES EXERPT.  VARIOUS RBCONFIGS EXIST
#  BASED ON VERSION NUMBERS
#==============================================================================

module RbConfig
  CONFIG = {}  
  CONFIG["host_os"] = "mingw32msvc"
end



#==============================================================================
# ** Operating System Detection
#------------------------------------------------------------------------------
#  This module actively uses the RbConfig system to detect what operating
#  system is in use.  The below code is sound, the RbConfig used above is
#  merely a snippet of the whole.
#
#  Refer to OS_Detect::execute to perform the operation
#==============================================================================

module OS_Detect
  #--------------------------------------------------------------------------
  # * Methods/Functions Executable From Outside Call
  #--------------------------------------------------------------------------
  module_function  
  #--------------------------------------------------------------------------
  # * Object Execution
  #--------------------------------------------------------------------------
  def execute
    @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
        raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
      end
    )
  end
end

  
# THIS prints the version
p OS_Detect::execute

You can replace the returned values (like :windows) with numeric values if it helps Winking

This will prove useful if one wishes to permit Win32DLL applications to run in their game for Windows Users, and perhaps have a workaround for those without.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }


Messages In This Thread
RE: Find out what's your file's architecture using Ruby! - by DerVVulfman - 09-08-2019, 06:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Ruby Builder v 0.2 Narzew 2 6,042 10-10-2012, 06:11 AM
Last Post: Narzew
   Rubular - a Ruby regular expression editor zecomeia 2 6,266 03-14-2010, 02:44 PM
Last Post: zecomeia



Users browsing this thread: 2 Guest(s)