Class | Gem::Requirement |
In: |
lib/rubygems/version.rb
|
Parent: | Object |
Requirement version includes a prefaced comparator in addition to a version number.
A Requirement object can actually contain multiple, er, requirements, as in (> 1.2, < 2.0).
OPS | = | { "=" => lambda { |v, r| v == r }, "!=" => lambda { |v, r| v != r }, ">" => lambda { |v, r| v > r }, "<" => lambda { |v, r| v < r }, ">=" => lambda { |v, r| v >= r }, "<=" => lambda { |v, r| v <= r }, "~>" => lambda { |v, r| v >= r && v < r.bump } |
OP_RE | = | Regexp.new(OPS.keys.collect{|k| Regexp.quote(k)}.join("|")) |
REQ_RE | = | /\s*(#{OP_RE})\s*/ |
Factory method to create a Version::Requirement object. Input may be a Version, a String, or nil. Intended to simplify client code.
If the input is "weird", the default version requirement is returned.
Constructs a version requirement instance
str: | [String Array] the version requirement string (e.g. ["> 1.23"]) |
Is the requirement satifised by version.
version: | [Gem::Version] the version to compare against |
return: | [Boolean] true if this requirement is satisfied by the version, otherwise false |