Class: DepSelector::Version
- Inherits:
-
Object
- Object
- DepSelector::Version
- Includes:
- Comparable
- Defined in:
- lib/dep_selector/version.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
- #<=>(v) ⇒ Object
-
#eql?(other) ⇒ Boolean
For hash.
- #hash ⇒ Object
-
#initialize(str = "") ⇒ Version
constructor
A new instance of Version.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str = "") ⇒ Version
Returns a new instance of Version.
27 28 29 |
# File 'lib/dep_selector/version.rb', line 27 def initialize(str="") @major, @minor, @patch = parse(str) end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
25 26 27 |
# File 'lib/dep_selector/version.rb', line 25 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
25 26 27 |
# File 'lib/dep_selector/version.rb', line 25 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
25 26 27 |
# File 'lib/dep_selector/version.rb', line 25 def patch @patch end |
Instance Method Details
#<=>(v) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/dep_selector/version.rb', line 39 def <=>(v) [:major, :minor, :patch].each do |method| ans = (self.send(method) <=> v.send(method)) return ans if ans != 0 end 0 end |
#eql?(other) ⇒ Boolean
For hash
54 55 56 |
# File 'lib/dep_selector/version.rb', line 54 def eql?(other) other.is_a?(Version) && self == other end |
#hash ⇒ Object
47 48 49 50 51 |
# File 'lib/dep_selector/version.rb', line 47 def hash # Didn't put any thought or research into this, probably can be # done better to_s.hash end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/dep_selector/version.rb', line 31 def inspect "#{@major}.#{@minor}.#{@patch}" end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/dep_selector/version.rb', line 35 def to_s "#{@major}.#{@minor}.#{@patch}" end |