Class: Android::Manifest::Component
- Inherits:
-
Object
- Object
- Android::Manifest::Component
- Defined in:
- lib/android/manifest.rb
Overview
<activity>, <service>, <receiver> or <provider> element in <application> element of the manifest file.
Constant Summary collapse
- TYPES =
component types
['service', 'activity', 'receiver', 'provider']
Instance Attribute Summary collapse
- #elem ⇒ REXML::Element readonly
- #intent_filters ⇒ Array<Manifest::IntentFilter> readonly
- #metas ⇒ Array<Manifest::Meta> readonly
-
#name ⇒ String
readonly
Component name.
-
#type ⇒ String
readonly
Type string in TYPES.
Class Method Summary collapse
-
.valid?(elem) ⇒ Boolean
the element is valid Component element or not.
Instance Method Summary collapse
-
#initialize(elem) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(elem) ⇒ Component
Returns a new instance of Component.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/android/manifest.rb', line 37 def initialize(elem) raise ArgumentError unless Component.valid?(elem) @elem = elem @type = elem.name @name = elem.attributes['name'] @intent_filters = [] unless elem.elements['intent-filter'].nil? elem.elements['intent-filter'].each do |e| next unless e.instance_of? REXML::Element @intent_filters << IntentFilter.parse(e) end end @metas = [] elem.each_element('meta-data') do |e| @metas << Meta.new(e) end end |
Instance Attribute Details
#elem ⇒ REXML::Element (readonly)
32 33 34 |
# File 'lib/android/manifest.rb', line 32 def elem @elem end |
#intent_filters ⇒ Array<Manifest::IntentFilter> (readonly)
28 29 30 |
# File 'lib/android/manifest.rb', line 28 def intent_filters @intent_filters end |
#metas ⇒ Array<Manifest::Meta> (readonly)
30 31 32 |
# File 'lib/android/manifest.rb', line 30 def @metas end |
#name ⇒ String (readonly)
Returns component name.
26 27 28 |
# File 'lib/android/manifest.rb', line 26 def name @name end |
#type ⇒ String (readonly)
Returns type string in TYPES.
24 25 26 |
# File 'lib/android/manifest.rb', line 24 def type @type end |
Class Method Details
.valid?(elem) ⇒ Boolean
the element is valid Component element or not
17 18 19 20 21 |
# File 'lib/android/manifest.rb', line 17 def self.valid?(elem) TYPES.include?(elem.name.downcase) rescue => e false end |