Class: DMAP::Version
- Inherits:
-
Object
- Object
- DMAP::Version
- Defined in:
- lib/dmap.rb
Overview
A class to store version numbers
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#maximus ⇒ Object
Returns the value of attribute maximus.
-
#minimus ⇒ Object
Returns the value of attribute minimus.
-
#minor ⇒ Object
Returns the value of attribute minor.
Instance Method Summary collapse
-
#initialize(version = "0.1.0.0") ⇒ Version
constructor
A new instance of Version.
- #inspect ⇒ Object
- #to_dmap ⇒ Object
Constructor Details
#initialize(version = "0.1.0.0") ⇒ Version
Returns a new instance of Version.
267 268 269 270 271 272 |
# File 'lib/dmap.rb', line 267 def initialize(version = "0.1.0.0") @maximus,@major,@minor,@minimus = (version.to_s<<".0.0.0").split(".").collect{|n| n.to_i } if @maximus > 255 or @major > 255 or @minor > 255 or @minimus > 255 raise RangeError "None of the version points can be above 255. Surely that's enough?" end end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
266 267 268 |
# File 'lib/dmap.rb', line 266 def major @major end |
#maximus ⇒ Object
Returns the value of attribute maximus.
266 267 268 |
# File 'lib/dmap.rb', line 266 def maximus @maximus end |
#minimus ⇒ Object
Returns the value of attribute minimus.
266 267 268 |
# File 'lib/dmap.rb', line 266 def minimus @minimus end |
#minor ⇒ Object
Returns the value of attribute minor.
266 267 268 |
# File 'lib/dmap.rb', line 266 def minor @minor end |
Instance Method Details
#inspect ⇒ Object
278 279 280 |
# File 'lib/dmap.rb', line 278 def inspect "v#{@maximus}.#{@major}.#{@minor}.#{@minimus}" end |
#to_dmap ⇒ Object
274 275 276 |
# File 'lib/dmap.rb', line 274 def to_dmap "\000\000\000\004"<<[@maximus,@major,@minor,@minimus].pack("CCCC") end |