Class: DebImporter::Version
- Inherits:
-
Object
- Object
- DebImporter::Version
- Defined in:
- lib/deb_importer.rb
Overview
def
Instance Attribute Summary collapse
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#upstream ⇒ Object
readonly
Returns the value of attribute upstream.
-
#version_string ⇒ Object
readonly
Returns the value of attribute version_string.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #>(other) ⇒ Object
-
#initialize(version_string) ⇒ Version
constructor
A new instance of Version.
-
#to_s ⇒ Object
/def.
Constructor Details
#initialize(version_string) ⇒ Version
Returns a new instance of Version.
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/deb_importer.rb', line 155 def initialize(version_string) @version_string = version_string # Split into "[epoch:]upstream[-revision]" # See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version unless /^((?<epoch>\d+)\:)?(?<upstream>.+?)(\-(?<revision>.+))?$/ =~ version_string raise ArgumentError, "Cannot parse version string: #{version_string}" end @epoch = epoch ? epoch : '0' @upstream = upstream @revision = revision if revision end |
Instance Attribute Details
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
153 154 155 |
# File 'lib/deb_importer.rb', line 153 def epoch @epoch end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
153 154 155 |
# File 'lib/deb_importer.rb', line 153 def revision @revision end |
#upstream ⇒ Object (readonly)
Returns the value of attribute upstream.
153 154 155 |
# File 'lib/deb_importer.rb', line 153 def upstream @upstream end |
#version_string ⇒ Object (readonly)
Returns the value of attribute version_string.
153 154 155 |
# File 'lib/deb_importer.rb', line 153 def version_string @version_string end |
Instance Method Details
#<(other) ⇒ Object
175 176 177 |
# File 'lib/deb_importer.rb', line 175 def <(other) dpkg_compare_version(@version_string, other, 'lt') end |
#>(other) ⇒ Object
171 172 173 |
# File 'lib/deb_importer.rb', line 171 def >(other) dpkg_compare_version(@version_string, other, 'gt') end |
#to_s ⇒ Object
/def
167 168 169 |
# File 'lib/deb_importer.rb', line 167 def to_s @version_string end |