Class: ReleaseTagger::Version

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#majorObject

Returns the value of attribute major

Returns:

  • (Object)

    the current value of major



7
8
9
# File 'lib/release_tagger.rb', line 7

def major
  @major
end

#minorObject

Returns the value of attribute minor

Returns:

  • (Object)

    the current value of minor



7
8
9
# File 'lib/release_tagger.rb', line 7

def minor
  @minor
end

#patchObject

Returns the value of attribute patch

Returns:

  • (Object)

    the current value of patch



7
8
9
# File 'lib/release_tagger.rb', line 7

def patch
  @patch
end

Instance Method Details

#bump(type) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/release_tagger.rb', line 8

def bump(type)
  raise ArgumentError,
    "Could not bump #{type} version" unless respond_to?(type)

  numbers =
    case type
    when "major" then [major + 1, 0,         0]
    when "minor" then [major,     minor + 1, 0]
    when "patch" then [major,     minor,     patch + 1]
    end

  self.class.new(*numbers)
end

#to_sObject



22
23
24
# File 'lib/release_tagger.rb', line 22

def to_s
  [major, minor, patch].join(".")
end