https://github.com/piotrmurach/tty-platform
Operating system detection
https://github.com/piotrmurach/tty-platform
platform ruby-gem terminal tty
Last synced: 4 months ago
JSON representation
Operating system detection
- Host: GitHub
- URL: https://github.com/piotrmurach/tty-platform
- Owner: piotrmurach
- License: mit
- Created: 2015-05-16T18:52:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-02-23T22:52:24.000Z (over 1 year ago)
- Last Synced: 2025-05-08T16:17:52.271Z (5 months ago)
- Topics: platform, ruby-gem, terminal, tty
- Language: Ruby
- Homepage: https://ttytoolkit.org
- Size: 40 KB
- Stars: 29
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TTY::Platform [][gitter]
[][gem]
[][gh_actions_ci]
[][appveyor]
[][codeclimate]
[][coverage]
[][inchpages][gitter]: https://gitter.im/piotrmurach/tty
[gem]: https://badge.fury.io/rb/tty-platform
[gh_actions_ci]: https://github.com/piotrmurach/tty-platform/actions?query=workflow%3ACI
[appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-platform
[codeclimate]: https://codeclimate.com/github/piotrmurach/tty-platform
[coverage]: https://coveralls.io/github/piotrmurach/tty-platform
[inchpages]: https://inch-ci.org/github/piotrmurach/tty-platform> Terminal platform query methods for detecting different operating systems and their properties.
**TTY::Platform** provides independent operating system detection component for [TTY](https://github.com/piotrmurach/tty) toolkit.
## Installation
Add this line to your application's Gemfile:
```ruby
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:
```ruby
platform = TTY::Platform.new
```To query for processor name use `cpu` method:
```ruby
platform.cpu # => 'x86_64'
```A `nil` is returned if the value cannot be determined.
To get the system/OS name use `os` method:
```ruby
platform.os # => 'darwin'
```A `nil` is returned if the value cannot be determined.
To get system's release version use `version` method:
```ruby
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`:
```ruby
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.