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.



270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/xcode/install.rb', line 270

def initialize(json)
  @date_modified = json['dateModified'].to_i
  @name = json['name'].gsub(/^Xcode /, '')
  @path = json['files'].first['remotePath']
  @url = "https://developer.apple.com/devcenter/download.action?path=#{@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.



264
265
266
# File 'lib/xcode/install.rb', line 264

def date_modified
  @date_modified
end

#nameObject (readonly)

Returns the value of attribute name.



265
266
267
# File 'lib/xcode/install.rb', line 265

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



266
267
268
# File 'lib/xcode/install.rb', line 266

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



267
268
269
# File 'lib/xcode/install.rb', line 267

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



268
269
270
# File 'lib/xcode/install.rb', line 268

def version
  @version
end

Class Method Details

.new_prelease(version, url) ⇒ Object



292
293
294
295
296
# File 'lib/xcode/install.rb', line 292

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

Instance Method Details

#==(other) ⇒ Object



287
288
289
290
# File 'lib/xcode/install.rb', line 287

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

#to_sObject



283
284
285
# File 'lib/xcode/install.rb', line 283

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