Class: OpenfireAdmin::VersionString

Inherits:
Object
  • Object
show all
Defined in:
lib/openfire_admin/version_string.rb

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ VersionString

Returns a new instance of VersionString.



3
4
5
# File 'lib/openfire_admin/version_string.rb', line 3

def initialize(version)
  @version = version.to_s.strip.split(/\./)
end

Instance Method Details

#<(other) ⇒ Object



12
13
14
# File 'lib/openfire_admin/version_string.rb', line 12

def < other
  (self <=> other) == -1
end

#<=(other) ⇒ Object



18
19
20
# File 'lib/openfire_admin/version_string.rb', line 18

def <= other
  (self <=> other) <= 0
end

#<=>(othre) ⇒ Object



6
7
8
# File 'lib/openfire_admin/version_string.rb', line 6

def <=>(othre)
  compare(@version.dup, othre.kind_of?(VersionString) ? othre.to_a.dup : othre.to_s.strip.split(/\./))
end

#==(other) ⇒ Object



21
22
23
# File 'lib/openfire_admin/version_string.rb', line 21

def == other
  (self <=> other) == 0
end

#>(other) ⇒ Object



9
10
11
# File 'lib/openfire_admin/version_string.rb', line 9

def > other
  (self <=> other) == 1
end

#>=(other) ⇒ Object



15
16
17
# File 'lib/openfire_admin/version_string.rb', line 15

def >= other
  (self <=> other) >= 0
end

#to_aObject



27
28
29
# File 'lib/openfire_admin/version_string.rb', line 27

def to_a
  @version
end

#to_sObject



24
25
26
# File 'lib/openfire_admin/version_string.rb', line 24

def to_s
  "VersionString(#{@version.join(".")})"
end