1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<div align="center">
<a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
</div>
# TTY::Platform [][gitter]
[][gem]
[][travis]
[][appveyor]
[][codeclimate]
[][coverage]
[][inchpages]
[gitter]: https://gitter.im/piotrmurach/tty
[gem]: http://badge.fury.io/rb/tty-platform
[travis]: http://travis-ci.org/piotrmurach/tty-platform
[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]: http://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.
|