File: README.md

package info (click to toggle)
ruby-ruby-version 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112 kB
  • sloc: ruby: 161; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,422 bytes parent folder | download
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
# RubyVersion [<img src="https://badge.fury.io/rb/ruby_version.svg" alt="Gem Version" />](https://badge.fury.io/rb/ruby_version) [<img src="https://github.com/janlelis/ruby_version/workflows/Test/badge.svg" />](https://github.com/janlelis/ruby_version/actions?query=workflow%3ATest)

Provides a `RubyVersion` to simplify checking for the right Ruby version in
your programs.

## Setup

On your command-line:

    $ gem install ruby_version

In Ruby:

    require 'ruby_version'

## Usage

    # Output RUBY_VERSION
    RubyVersion.to_s

    # Check for the main version with a Float
    RubyVersion.is? 2.1

    # Use strings for exacter checking
    RubyVersion.is.above '1.9.2'
    RubyVersion.is.at_least '2.0.0' # or exactly, below, at_most

    # You can use the common comparison operators
    RubyVersion >= '1.8.7'
    RubyVersion.between? '1.8.7', '1.9.2'

    # Relase date checks
    RubyVersion.is.older_than Date.today
    RubyVersion.is.newer_than '2009-08-19'

    # Misc Accessors
    RubyVersion.major # => 1
    RubyVersion.minor # => 8
    RubyVersion.tiny  # => 7
    RubyVersion.patchlevel # => 249
    RubyVersion.description # => "ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]"

## Also See

- https://github.com/janlelis/ruby_engine
- https://github.com/janlelis/ruby_info
- https://github.com/rdp/os

## J-_-L

Copyright (c) 2010-2014 Jan Lelis. MIT License. Originated from the zucker gem.