Class: XcodeInstall::Xcode

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Xcode

Returns a new instance of Xcode.



303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/xcode/install.rb', line 303

def initialize(json)
  @date_modified = json['dateModified'].to_i
  @name = json['name'].gsub(/^Xcode /, '')
  @path = json['files'].first['remotePath']
  url_prefix = 'https://developer.apple.com/devcenter/download.action?path='
  @url = "#{url_prefix}#{@path}"
  @release_notes_url = "#{url_prefix}#{json['release_notes_path']}" if json['release_notes_path']

  begin
    @version = Gem::Version.new(@name.split(' ')[0])
  rescue
    @version = Installer::MINIMUM_VERSION
  end
end

Instance Attribute Details

#date_modifiedObject (readonly)

Returns the value of attribute date_modified.



296
297
298
# File 'lib/xcode/install.rb', line 296

def date_modified
  @date_modified
end

#nameObject (readonly)

Returns the value of attribute name.



297
298
299
# File 'lib/xcode/install.rb', line 297

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



298
299
300
# File 'lib/xcode/install.rb', line 298

def path
  @path
end

#release_notes_urlObject (readonly)

Returns the value of attribute release_notes_url.



301
302
303
# File 'lib/xcode/install.rb', line 301

def release_notes_url
  @release_notes_url
end

#urlObject (readonly)

Returns the value of attribute url.



299
300
301
# File 'lib/xcode/install.rb', line 299

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



300
301
302
# File 'lib/xcode/install.rb', line 300

def version
  @version
end

Class Method Details

.new_prerelease(version, url, release_notes_path) ⇒ Object



327
328
329
330
331
332
# File 'lib/xcode/install.rb', line 327

def self.new_prerelease(version, url, release_notes_path)
  new('name' => version,
      'dateModified' => Time.now.to_i,
      'files' => [{ 'remotePath' => url.split('=').last }],
      'release_notes_path' => release_notes_path)
end

Instance Method Details

#==(other) ⇒ Object



322
323
324
325
# File 'lib/xcode/install.rb', line 322

def ==(other)
  date_modified == other.date_modified && name == other.name && path == other.path && \
    url == other.url && version == other.version
end

#to_sObject



318
319
320
# File 'lib/xcode/install.rb', line 318

def to_s
  "Xcode #{version} -- #{url}"
end