Class: WonkoTheSane::Util::VersionParser
- Inherits:
-
Object
- Object
- WonkoTheSane::Util::VersionParser
- Defined in:
- lib/wonko_the_sane/util/version_parser.rb
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
Class Method Summary collapse
- .compare(string1, string2) ⇒ Object
- .equal?(string1, string2) ⇒ Boolean
- .greater?(string1, string2) ⇒ Boolean
- .greater_or_equal?(string1, string2) ⇒ Boolean
- .less?(string1, string2) ⇒ Boolean
- .less_or_equal?(string1, string2) ⇒ Boolean
- .not_equal?(string1, string2) ⇒ Boolean
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
6 7 8 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 6 def cache @cache end |
Class Method Details
.compare(string1, string2) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 57 def self.compare(string1, string2) par1 = VersionParser.parse string1 par2 = VersionParser.parse string2 size = [par1[:sections].length, par2[:sections].length].max ret = 0 size.times do |index| val1 = par1[:sections].length > index ? par1[:sections][index] : 0 val2 = par2[:sections].length > index ? par2[:sections][index] : 0 ret = VersionParser.compare_values val1.to_i, val2.to_i break unless ret == 0 end if ret == 0 if par1[:appendix] && par2[:appendix] appendix1 = VersionParser.appendix_values par1[:appendix] appendix2 = VersionParser.appendix_values par2[:appendix] ret = VersionParser.compare_values appendix1[0], appendix2[0] if ret == 0 ret = VersionParser.compare_values appendix1[1], appendix2[1] end elsif par1[:appendix] ret = -1 elsif par2[:appendix] ret = 1 end end return ret end |
.equal?(string1, string2) ⇒ Boolean
91 92 93 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 91 def self.equal?(string1, string2) VersionParser.compare(string1, string2) == 0 end |
.greater?(string1, string2) ⇒ Boolean
88 89 90 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 88 def self.greater?(string1, string2) VersionParser.compare(string1, string2) == 1 end |
.greater_or_equal?(string1, string2) ⇒ Boolean
98 99 100 101 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 98 def self.greater_or_equal?(string1, string2) ret = VersionParser.compare string1, string2 ret == 0 or ret == 1 end |
.less?(string1, string2) ⇒ Boolean
85 86 87 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 85 def self.less?(string1, string2) VersionParser.compare(string1, string2) == -1 end |
.less_or_equal?(string1, string2) ⇒ Boolean
94 95 96 97 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 94 def self.less_or_equal?(string1, string2) ret = VersionParser.compare string1, string2 ret == 0 or ret == -1 end |
.not_equal?(string1, string2) ⇒ Boolean
102 103 104 |
# File 'lib/wonko_the_sane/util/version_parser.rb', line 102 def self.not_equal?(string1, string2) VersionParser.compare(string1, string2) != 0 end |