Class: Kibosh::Session::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/kibosh/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ver) ⇒ Version

Returns a new instance of Version.



21
22
23
24
25
# File 'lib/kibosh/session.rb', line 21

def initialize ver
  m = %r{^(\d+).(\d+)$}.match ver
  raise BadRequest.new nil, "Bad version format: #{ver}" if !m
  @major, @minor = m[1].to_i, m[2].to_i
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



20
21
22
# File 'lib/kibosh/session.rb', line 20

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



20
21
22
# File 'lib/kibosh/session.rb', line 20

def minor
  @minor
end

Instance Method Details

#<=>(other) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/kibosh/session.rb', line 26

def <=> other
  diff = @major - other.major
  if diff == 0
    diff = @minor - other.minor
  end
  diff
end

#to_sObject



33
34
35
# File 'lib/kibosh/session.rb', line 33

def to_s
  "#{@major}.#{@minor}"
end