Class: Dumbo::ExtensionVersion

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/dumbo/extension_version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#majorObject

Returns the value of attribute major

Returns:

  • (Object)

    the current value of major



2
3
4
# File 'lib/dumbo/extension_version.rb', line 2

def major
  @major
end

#minorObject

Returns the value of attribute minor

Returns:

  • (Object)

    the current value of minor



2
3
4
# File 'lib/dumbo/extension_version.rb', line 2

def minor
  @minor
end

#patchObject

Returns the value of attribute patch

Returns:

  • (Object)

    the current value of patch



2
3
4
# File 'lib/dumbo/extension_version.rb', line 2

def patch
  @patch
end

Class Method Details

.new_from_string(version) ⇒ Object



6
7
8
# File 'lib/dumbo/extension_version.rb', line 6

def new_from_string(version)
  ExtensionVersion.new(*version.split('.').map(&:to_i))
end

.sortObject



10
11
12
# File 'lib/dumbo/extension_version.rb', line 10

def sort
  sort! { |a, b| a <=> b }
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
18
19
# File 'lib/dumbo/extension_version.rb', line 15

def <=>(other)
  return major <=> other.major if (major <=> other.major) != 0
  return minor <=> other.minor if (minor <=> other.minor) != 0
  return patch <=> other.patch if (patch <=> other.patch) != 0
end

#bump(level) ⇒ Object



21
22
23
# File 'lib/dumbo/extension_version.rb', line 21

def bump(level)
  send("bump_#{level}")
end

#to_sObject



25
26
27
# File 'lib/dumbo/extension_version.rb', line 25

def to_s
  to_a.compact.join('.')
end