Class: XcodeInstall::InstalledXcode

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/install.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ InstalledXcode

Returns a new instance of InstalledXcode.



252
253
254
255
# File 'lib/xcode/install.rb', line 252

def initialize(path)
  @path = Pathname.new(path)
  @version = get_version(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



249
250
251
# File 'lib/xcode/install.rb', line 249

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



250
251
252
# File 'lib/xcode/install.rb', line 250

def version
  @version
end

Instance Method Details

#get_version(xcode_path) ⇒ Object



259
260
261
262
263
# File 'lib/xcode/install.rb', line 259

def get_version(xcode_path)
  output = `DEVELOPER_DIR='' "#{xcode_path}/Contents/Developer/usr/bin/xcodebuild" -version`
  return '0.0' if output.nil? # ¯\_(ツ)_/¯
  output.split("\n").first.split(' ')[1]
end