Class: Mongo::ServerVersion
- Includes:
- Comparable
- Defined in:
- lib/mongo/util/server_version.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.
21 22 23 |
# File 'lib/mongo/util/server_version.rb', line 21 def initialize(version) @version = version end |
Instance Method Details
#<=>(new) ⇒ Object
Implements comparable.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mongo/util/server_version.rb', line 26 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.
42 43 44 |
# File 'lib/mongo/util/server_version.rb', line 42 def to_a to_array(@version) end |
#to_s ⇒ Object
Return a string representation of this server version.
47 48 49 |
# File 'lib/mongo/util/server_version.rb', line 47 def to_s @version end |