Class: DMAP::Version

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

Overview

A class to store version numbers

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#majorObject

Returns the value of attribute major.



266
267
268
# File 'lib/dmap.rb', line 266

def major
  @major
end

#maximusObject

Returns the value of attribute maximus.



266
267
268
# File 'lib/dmap.rb', line 266

def maximus
  @maximus
end

#minimusObject

Returns the value of attribute minimus.



266
267
268
# File 'lib/dmap.rb', line 266

def minimus
  @minimus
end

#minorObject

Returns the value of attribute minor.



266
267
268
# File 'lib/dmap.rb', line 266

def minor
  @minor
end

Instance Method Details

#inspectObject



278
279
280
# File 'lib/dmap.rb', line 278

def inspect
  "v#{@maximus}.#{@major}.#{@minor}.#{@minimus}"
end

#to_dmapObject



274
275
276
# File 'lib/dmap.rb', line 274

def to_dmap
  "\000\000\000\004"<<[@maximus,@major,@minor,@minimus].pack("CCCC")
end