Class: AppInfo::Protobuf::Resources

Inherits:
Object
  • Object
show all
Includes:
Helper::Protobuf
Defined in:
lib/app_info/protobuf/resources.rb

Defined Under Namespace

Classes: Entry, Package, Value

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::Protobuf

#reference_segments

Constructor Details

#initialize(doc) ⇒ Resources

Returns a new instance of Resources.



19
20
21
# File 'lib/app_info/protobuf/resources.rb', line 19

def initialize(doc)
  parse(doc)
end

Instance Attribute Details

#packagesObject (readonly)

Returns the value of attribute packages.



17
18
19
# File 'lib/app_info/protobuf/resources.rb', line 17

def packages
  @packages
end

#tool_fingerprintObject (readonly)

Returns the value of attribute tool_fingerprint.



17
18
19
# File 'lib/app_info/protobuf/resources.rb', line 17

def tool_fingerprint
  @tool_fingerprint
end

Class Method Details

.parse(io) ⇒ Object



10
11
12
13
# File 'lib/app_info/protobuf/resources.rb', line 10

def self.parse(io)
  doc = Aapt::Pb::ResourceTable.decode(io)
  new(doc)
end

Instance Method Details

#find(reference, locale: '') ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/app_info/protobuf/resources.rb', line 23

def find(reference, locale: '')
  type, name = reference_segments(reference)
  packages.each_value do |package|
    next unless value = package.find(name, type: type, locale: locale)

    return value
  end

  nil
end

#first_packageObject



34
35
36
# File 'lib/app_info/protobuf/resources.rb', line 34

def first_package
  packages.values[0]
end