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.
| 23 24 25 | # File 'lib/mongo/util/server_version.rb', line 23 def initialize(version) @version = version end | 
Instance Method Details
#<=>(new) ⇒ Object
Implements comparable.
| 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # File 'lib/mongo/util/server_version.rb', line 28 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.
| 44 45 46 | # File 'lib/mongo/util/server_version.rb', line 44 def to_a to_array(@version) end | 
#to_s ⇒ Object
Return a string representation of this server version.
| 49 50 51 | # File 'lib/mongo/util/server_version.rb', line 49 def to_s @version end |