Class: Mongo::ServerVersion
- Includes:
- Comparable
- Defined in:
- lib/jmongo/mongo/mongo.rb
Overview
Simple class for comparing server versions.
Instance Method Summary collapse
-
#<=>(new) ⇒ Object
Implements comparable.
-
#initialize(version) ⇒ ServerVersion
constructor
A new instance of ServerVersion.
-
#to_a ⇒ Object
Return an array representation of this server version.
-
#to_s ⇒ Object
Return a string representation of this server version.
Constructor Details
#initialize(version) ⇒ ServerVersion
Returns a new instance of ServerVersion.
50 51 52 |
# File 'lib/jmongo/mongo/mongo.rb', line 50 def initialize(version) @version = version end |
Instance Method Details
#<=>(new) ⇒ Object
Implements comparable.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jmongo/mongo/mongo.rb', line 55 def <=>(new) local, new = self.to_a, to_array(new) for n in 0...local.size do break if elements_include_mods?(local[n], new[n]) if local[n] < new[n].to_i result = -1 break; elsif local[n] > new[n].to_i result = 1 break; end end result || 0 end |
#to_a ⇒ Object
Return an array representation of this server version.
71 72 73 |
# File 'lib/jmongo/mongo/mongo.rb', line 71 def to_a to_array(@version) end |
#to_s ⇒ Object
Return a string representation of this server version.
76 77 78 |
# File 'lib/jmongo/mongo/mongo.rb', line 76 def to_s @version end |