Class: U3d::UnityVersionDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/u3d/unity_version_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, os, cached_versions, offline: false) ⇒ UnityVersionDefinition

Returns a new instance of UnityVersionDefinition.



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

def initialize(version, os, cached_versions, offline: false)
  @version = version
  @os = os
  # Cache is assumed to be correct
  @url = cached_versions ? cached_versions[version] : nil
  begin
    @ini = INIparser.load_ini(version, cached_versions, os: os, offline: offline)
  rescue StandardError => e
    # FIXME: weird that we catch this here
    UI.error "Could not load INI file for version #{@version} on #{@os}: #{e}"
    @ini = nil
  end
end

Instance Attribute Details

#iniObject

Returns the value of attribute ini.



27
28
29
# File 'lib/u3d/unity_version_definition.rb', line 27

def ini
  @ini
end

#osObject

Returns the value of attribute os.



27
28
29
# File 'lib/u3d/unity_version_definition.rb', line 27

def os
  @os
end

#urlObject

Returns the value of attribute url.



27
28
29
# File 'lib/u3d/unity_version_definition.rb', line 27

def url
  @url
end

#versionObject

Returns the value of attribute version.



27
28
29
# File 'lib/u3d/unity_version_definition.rb', line 27

def version
  @version
end

Instance Method Details

#[](key) ⇒ Object



51
52
53
54
# File 'lib/u3d/unity_version_definition.rb', line 51

def [](key)
  return nil unless @ini
  @ini[key]
end

#available_package?(p) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/u3d/unity_version_definition.rb', line 47

def available_package?(p)
  available_packages.include? p
end

#available_packagesObject



43
44
45
# File 'lib/u3d/unity_version_definition.rb', line 43

def available_packages
  @ini.keys
end

#size_in_bytes(package) ⇒ Object



56
57
58
59
60
# File 'lib/u3d/unity_version_definition.rb', line 56

def size_in_bytes(package)
  return nil unless @ini
  return -1 unless @ini[package] && @ini[package]['size']
  @os == :win ? @ini[package]['size'] * 1024 : @ini[package]['size']
end