Class: Hackmac::KextDownload

Inherits:
Object
  • Object
show all
Includes:
Tins::StringVersion
Defined in:
lib/hackmac/kext_download.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, url) ⇒ KextDownload

Returns a new instance of KextDownload.



8
9
10
11
12
# File 'lib/hackmac/kext_download.rb', line 8

def initialize(name, version, url)
  @name    = name
  @url     = url
  @version = Version.new(version)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/hackmac/kext_download.rb', line 14

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



16
17
18
# File 'lib/hackmac/kext_download.rb', line 16

def version
  @version
end

Instance Method Details

#download_assetObject



18
19
20
21
22
23
24
25
# File 'lib/hackmac/kext_download.rb', line 18

def download_asset
  data = URI.open(
    @url,
    'Accept' => 'application/octet-stream',
    &:read
  )
  return File.basename(@url), data
end

#inspectObject



27
28
29
# File 'lib/hackmac/kext_download.rb', line 27

def inspect
  "#<#{self.class}: #{to_s}>"
end

#to_sObject



31
32
33
# File 'lib/hackmac/kext_download.rb', line 31

def to_s
  "#{name} #{version}"
end