Class: AppInfo::HarmonyOS

Inherits:
File
  • Object
show all
Extended by:
Forwardable
Includes:
AppInfo::Helper::Archive, AppInfo::Helper::HumanFileSize
Defined in:
lib/app_info/harmonyos.rb

Overview

HarmonyOS base parser for hap and app file

Direct Known Subclasses

HAP, HAPP

Constant Summary

Constants included from AppInfo::Helper::HumanFileSize

AppInfo::Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods included from AppInfo::Helper::Archive

#tempdir, #unarchive

Methods included from AppInfo::Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#format, #initialize, #not_implemented_error!

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#clear!Object

This method is abstract.

Subclass and override #clear! to implement.



61
62
63
# File 'lib/app_info/harmonyos.rb', line 61

def clear!
  not_implemented_error!(__method__)
end

#contentsString

Returns unzipped file path.

Returns:

  • (String)

    unzipped file path



51
52
53
# File 'lib/app_info/harmonyos.rb', line 51

def contents
  @contents ||= unarchive(@file, prefix: format.to_s)
end

#deviceSymbol

Returns Device.

Returns:



36
37
38
# File 'lib/app_info/harmonyos.rb', line 36

def device
  Device::Huawei::DEFAULT
end

#info_pathString

Returns:

  • (String)


46
47
48
# File 'lib/app_info/harmonyos.rb', line 46

def info_path
  @info_path ||= ::File.join(contents, 'pack.info')
end

#manufacturerSymbol

Returns Manufacturer.

Returns:



26
27
28
# File 'lib/app_info/harmonyos.rb', line 26

def manufacturer
  Manufacturer::HUAWEI
end

#nameObject

This method is abstract.

Subclass and override #name to implement.



56
57
58
# File 'lib/app_info/harmonyos.rb', line 56

def name
  not_implemented_error!(__method__)
end

#pack_infoPackInfo

Returns:



41
42
43
# File 'lib/app_info/harmonyos.rb', line 41

def pack_info
  @pack_info ||= PackInfo.new(info_path)
end

#platformSymbol

Returns Platform.

Returns:



31
32
33
# File 'lib/app_info/harmonyos.rb', line 31

def platform
  Platform::HARMONYOS
end

#size(human_size: false) ⇒ Integer, String

return file size

Examples:

Read file size in integer

aab.size                    # => 3618865

Read file size in human readabale

aab.size(human_size: true)  # => '3.45 MB'

Parameters:

  • human_size (Boolean) (defaults to: false)

    Convert integer value to human readable.

Returns:

  • (Integer, String)


21
22
23
# File 'lib/app_info/harmonyos.rb', line 21

def size(human_size: false)
  file_to_human_size(@file, human_size: human_size)
end