Class: Babeltrace2::BTVersion::Number

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/babeltrace2/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor, patch, extra = nil) ⇒ Number

Returns a new instance of Number.



47
48
49
50
51
52
# File 'lib/babeltrace2/version.rb', line 47

def initialize(major, minor, patch, extra = nil)
  @major = major
  @minor = minor
  @patch = patch
  @extra = extra
end

Instance Attribute Details

#extraObject (readonly)

Returns the value of attribute extra.



46
47
48
# File 'lib/babeltrace2/version.rb', line 46

def extra
  @extra
end

#majorObject (readonly)

Returns the value of attribute major.



46
47
48
# File 'lib/babeltrace2/version.rb', line 46

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



46
47
48
# File 'lib/babeltrace2/version.rb', line 46

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



46
47
48
# File 'lib/babeltrace2/version.rb', line 46

def patch
  @patch
end

Instance Method Details

#<=>(other) ⇒ Object



64
65
66
# File 'lib/babeltrace2/version.rb', line 64

def <=>(other)
  to_a <=> other.to_a
end

#to_aObject



60
61
62
# File 'lib/babeltrace2/version.rb', line 60

def to_a
  [@major, @minor, @patch]
end

#to_sObject



54
55
56
57
58
# File 'lib/babeltrace2/version.rb', line 54

def to_s
  str = "#{@major}.#{@minor}.#{@patch}"
  str << " (#{extra})" if extra
  str
end