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



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

def major
  @major
end

#minorObject

Returns the value of attribute minor



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

def minor
  @minor
end

#patchObject

Returns the value of attribute patch



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

def patch
  @patch
end

Instance Method Details

#bump(type) ⇒ Object

Raises:

  • (ArgumentError)


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

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



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

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