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.



255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/xcode/install.rb', line 255

def initialize(json)
  @dateModified = 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

#dateModifiedObject (readonly)

Returns the value of attribute dateModified.



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

def dateModified
  @dateModified
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.new_prelease(version, url) ⇒ Object



277
278
279
280
281
# File 'lib/xcode/install.rb', line 277

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

Instance Method Details

#==(o) ⇒ Object



272
273
274
275
# File 'lib/xcode/install.rb', line 272

def ==(o)
  dateModified == o.dateModified && name == o.name && path == o.path && \
    url == o.url && version == o.version
end

#to_sObject



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

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