Class: AppInfo::Protobuf::Manifest::IntentFilter

Inherits:
Node show all
Defined in:
lib/app_info/protobuf/manifest.rb

Constant Summary collapse

TYPES =

filter types (action is required, category and data are optional)

%w[action category data].freeze
%w[http https].freeze
CATEGORY_BROWSABLE =

browsable of category

'android.intent.category.BROWSABLE'

Instance Attribute Summary

Attributes inherited from Node

#attributes, #children, #name

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helper::Defines

#create_class, #define_instance_method

Constructor Details

This class inherits a constructor from AppInfo::Protobuf::Base

Instance Method Details

#browsable?Boolean

Returns:

  • (Boolean)


208
209
210
# File 'lib/app_info/protobuf/manifest.rb', line 208

def browsable?
  exist?(CATEGORY_BROWSABLE)
end


188
189
190
191
192
193
194
# File 'lib/app_info/protobuf/manifest.rb', line 188

def deep_links
  return unless deep_links?

  data.reject { |d| d.host.nil? }
      .map(&:host)
      .uniq
end

#deep_links?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/app_info/protobuf/manifest.rb', line 184

def deep_links?
  browsable? && data.any? { |d| DEEP_LINK_SCHEMES.include?(d.scheme) }
end

#exist?(name, type: nil) ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
215
216
217
218
219
220
221
222
# File 'lib/app_info/protobuf/manifest.rb', line 212

def exist?(name, type: nil)
  if type.to_s.empty? && !name.start_with?('android.intent.')
    raise 'Fill type or use correct name'
  end

  type ||= name.split('.')[2]
  raise 'Not found type' unless TYPES.include?(type)

  values = send(type.to_sym).select { |e| e.name == name }
  values.empty? ? false : values
end

#schemesObject



196
197
198
199
200
201
202
# File 'lib/app_info/protobuf/manifest.rb', line 196

def schemes
  return unless schemes?

  data.select { |d| !d.scheme.nil? && !DEEP_LINK_SCHEMES.include?(d.scheme) }
      .map(&:scheme)
      .uniq
end

#schemes?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/app_info/protobuf/manifest.rb', line 204

def schemes?
  browsable? && data.any? { |d| !DEEP_LINK_SCHEMES.include?(d.scheme) }
end