Class: Download

Inherits:
Object
  • Object
show all
Defined in:
lib/wonko_the_sane/wonko_version.rb

Direct Known Subclasses

FileDownload, VersionLibrary

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#internalUrlObject

not serialized, used for DownloadsFixer when the url isn’t direct (requires user interaction)



2
3
4
# File 'lib/wonko_the_sane/wonko_version.rb', line 2

def internalUrl
  @internalUrl
end

#rulesObject

Rule


6
7
8
# File 'lib/wonko_the_sane/wonko_version.rb', line 6

def rules
  @rules
end

#sha256Object

Returns the value of attribute sha256.



5
6
7
# File 'lib/wonko_the_sane/wonko_version.rb', line 5

def sha256
  @sha256
end

#sizeObject

Returns the value of attribute size.



4
5
6
# File 'lib/wonko_the_sane/wonko_version.rb', line 4

def size
  @size
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/wonko_the_sane/wonko_version.rb', line 3

def url
  @url
end

Class Method Details

.from_json(type, json) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/wonko_the_sane/wonko_version.rb', line 29

def self.from_json(type, json)
  dl = nil
  case type
  when 'java.libraries'
    dl = VersionLibrary.new
  when 'java.natives'
    dl = VersionLibraryNative.new
  when 'general.downloads'
    dl = FileDownload.new
  end

  dl.from_json json
  return dl
end

Instance Method Details

#from_json(json) ⇒ Object



22
23
24
25
26
27
# File 'lib/wonko_the_sane/wonko_version.rb', line 22

def from_json(json)
  @url = json[:url]
  @size = json[:size]
  @sha256 = json[:sha256]
  @rules = json[:rules].map do |obj| Rule.from_json obj end if json[:rules]
end

#to_jsonObject



12
13
14
15
16
17
18
19
20
# File 'lib/wonko_the_sane/wonko_version.rb', line 12

def to_json
  obj = {
    url: url,
    size: @size,
    sha256: @sha256
  }
  obj[:rules] = @rules.map do |rule| rule.to_json end if @rules and not @rules.empty?
  return obj
end

#typeObject



8
9
10
# File 'lib/wonko_the_sane/wonko_version.rb', line 8

def type
  'general.downloads'
end