Class: OSGi::Version
Overview
A class to represent OSGi versions.
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#qualifier ⇒ Object
Returns the value of attribute qualifier.
-
#tiny ⇒ Object
Returns the value of attribute tiny.
Instance Method Summary collapse
-
#<(other) ⇒ Object
:nodoc:.
-
#<=(other) ⇒ Object
:nodoc:.
-
#<=>(other) ⇒ Object
:nodoc:.
-
#==(other) ⇒ Object
:nodoc:.
-
#>(other) ⇒ Object
:nodoc:.
-
#>=(other) ⇒ Object
:nodoc:.
-
#initialize(string) ⇒ Version
constructor
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
Constructor Details
#initialize(string) ⇒ Version
:nodoc:
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/buildr4osgi/osgi/version.rb', line 25 def initialize(string) #:nodoc: digits = string.gsub(/\"/, '').split(".") @major = digits[0] @minor = digits[1] @tiny = digits[2] @qualifier = digits[3] raise "Invalid version: " + self.to_s if @major == "" raise "Invalid version: " + self.to_s if @minor == "" && (!@tiny != "" || !@qualifier != "") raise "Invalid version: " + self.to_s if @tiny == "" && !@qualifier != "" end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
23 24 25 |
# File 'lib/buildr4osgi/osgi/version.rb', line 23 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
23 24 25 |
# File 'lib/buildr4osgi/osgi/version.rb', line 23 def minor @minor end |
#qualifier ⇒ Object
Returns the value of attribute qualifier.
23 24 25 |
# File 'lib/buildr4osgi/osgi/version.rb', line 23 def qualifier @qualifier end |
#tiny ⇒ Object
Returns the value of attribute tiny.
23 24 25 |
# File 'lib/buildr4osgi/osgi/version.rb', line 23 def tiny @tiny end |
Instance Method Details
#<(other) ⇒ Object
:nodoc:
64 65 66 |
# File 'lib/buildr4osgi/osgi/version.rb', line 64 def <(other) #:nodoc: (self.<=>(other)) == -1 end |
#<=(other) ⇒ Object
:nodoc:
76 77 78 |
# File 'lib/buildr4osgi/osgi/version.rb', line 76 def <=(other) #:nodoc: (self.==(other)) || (self.<(other)) end |
#<=>(other) ⇒ Object
:nodoc:
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/buildr4osgi/osgi/version.rb', line 45 def <=>(other) #:nodoc: if other.is_a? String other = Version.new(other) elsif other.nil? return 1 end [:major, :minor, :tiny, :qualifier].each do |digit| return 0 if send(digit).nil? or other.send(digit).nil? comparison = send(digit) <=> other.send(digit) if comparison != 0 return comparison end end return 0 end |
#==(other) ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/buildr4osgi/osgi/version.rb', line 72 def ==(other) #:nodoc: (self.<=>(other)) == 0 end |
#>(other) ⇒ Object
:nodoc:
68 69 70 |
# File 'lib/buildr4osgi/osgi/version.rb', line 68 def >(other) #:nodoc: (self.<=>(other)) == 1 end |
#>=(other) ⇒ Object
:nodoc:
80 81 82 |
# File 'lib/buildr4osgi/osgi/version.rb', line 80 def >=(other) #:nodoc: (self.==(other)) || (self.>(other)) end |
#to_s ⇒ Object
:nodoc:
37 38 39 40 41 42 43 |
# File 'lib/buildr4osgi/osgi/version.rb', line 37 def to_s #:nodoc: str = [major] str << minor if minor str << tiny if minor && tiny str << qualifier if minor && tiny && qualifier str.compact.join(".") end |