0.02
No release in over 3 years
Low commit activity in last 3 years
Query methods for detecting different operating systems and their properties.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.5
>= 0
~> 3.1
 Project Readme
TTY Toolkit logo

TTY::Platform Gitter

Gem Version Actions CI Build status Code Climate Coverage Status Inline docs

Terminal platform query methods for detecting different operating systems and their properties.

TTY::Platform provides independent operating system detection component for TTY toolkit.

Installation

Add this line to your application's Gemfile:

gem 'tty-platform'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tty-platform

1. Usage

With TTY::Platform you can find out the properties of your operating system by creating an instance:

platform = TTY::Platform.new

To query for processor name use cpu method:

platform.cpu     # => 'x86_64'

A nil is returned if the value cannot be determined.

To get the system/OS name use os method:

platform.os      # => 'darwin'

A nil is returned if the value cannot be determined.

To get system's release version use version method:

platform.version # => '10.6.1'

A nil is returned. Note that many platforms do not provide this information.

In addition, you can use more generic methods to check the type of operating system out of windows, linux, mac and unix:

platform.windows?  # => false
platform.unix?     # => true
platform.linux?    # => false
platform.mac?      # => true

Contributing

  1. Fork it ( https://github.com/piotrmurach/tty-platform/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Copyright

Copyright (c) 2015 Piotr Murach. See LICENSE for further details.