Class: Xcode::Project::Version

Inherits:
PlistChanger show all
Defined in:
lib/xcode/project/version.rb

Constant Summary collapse

KEY =
'CFBundleShortVersionString'

Instance Attribute Summary collapse

Attributes inherited from PlistChanger

#plist_path

Instance Method Summary collapse

Methods inherited from PlistChanger

#initialize, #read, #write

Constructor Details

This class inherits a constructor from Xcode::Project::PlistChanger

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



4
5
6
# File 'lib/xcode/project/version.rb', line 4

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



4
5
6
# File 'lib/xcode/project/version.rb', line 4

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



4
5
6
# File 'lib/xcode/project/version.rb', line 4

def patch
  @patch
end

Instance Method Details

#bump_majorObject



21
22
23
24
25
# File 'lib/xcode/project/version.rb', line 21

def bump_major
  @major += 1
  @minor, @patch = 0, 0
  self
end

#bump_minorObject



27
28
29
30
31
# File 'lib/xcode/project/version.rb', line 27

def bump_minor
  @minor += 1
  @patch = 0
  self
end

#bump_patchObject



33
34
35
36
# File 'lib/xcode/project/version.rb', line 33

def bump_patch
  @patch += 1
  self
end

#set(string) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/xcode/project/version.rb', line 12

def set(string)
  if /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/ =~ string
    @major, @minor, @patch = $1.to_i, $2.to_i, $3.to_i
    self
  else
    raise "Can't parse version #{string.inspect}"
  end
end

#to_sObject



8
9
10
# File 'lib/xcode/project/version.rb', line 8

def to_s
  "#{major}.#{minor}.#{patch}".sub(/\.0/, '')
end