Class: AdLocalize::Entities::Key
- Inherits:
-
Object
- Object
- AdLocalize::Entities::Key
- Defined in:
- lib/ad_localize/entities/key.rb
Constant Summary collapse
- PLURAL_KEY_REGEXP =
/\#\#\{([A-Za-z]+)\}/.freeze
- ADAPTIVE_KEY_REGEXP =
/\#\#\{(\d+)\}/.freeze
- INFO_PLIST_KEY_REGEXP =
/(NS.+UsageDescription)|(CF.+Name)|NFCReaderUsageDescription/.freeze
Instance Method Summary collapse
- #==(o) ⇒ Object
- #adaptive? ⇒ Boolean
- #adaptive_key ⇒ Object
- #info_plist? ⇒ Boolean
-
#initialize(label:) ⇒ Key
constructor
A new instance of Key.
- #label ⇒ Object
- #plural? ⇒ Boolean
- #plural_key ⇒ Object
- #raw_label ⇒ Object
- #same_as?(key:) ⇒ Boolean
- #singular? ⇒ Boolean
Constructor Details
#initialize(label:) ⇒ Key
Returns a new instance of Key.
9 10 11 |
# File 'lib/ad_localize/entities/key.rb', line 9 def initialize(label:) @label = label end |
Instance Method Details
#==(o) ⇒ Object
49 50 51 52 |
# File 'lib/ad_localize/entities/key.rb', line 49 def ==(o) o.class == self.class && o.raw_label == raw_label end |
#adaptive? ⇒ Boolean
21 22 23 |
# File 'lib/ad_localize/entities/key.rb', line 21 def adaptive? adaptive_key.present? end |
#adaptive_key ⇒ Object
25 26 27 |
# File 'lib/ad_localize/entities/key.rb', line 25 def adaptive_key @adaptive_key ||= compute_adaptive_key end |
#info_plist? ⇒ Boolean
29 30 31 |
# File 'lib/ad_localize/entities/key.rb', line 29 def info_plist? @label.match(INFO_PLIST_KEY_REGEXP).present? end |
#label ⇒ Object
37 38 39 |
# File 'lib/ad_localize/entities/key.rb', line 37 def label compute_label.strip end |
#plural? ⇒ Boolean
17 18 19 |
# File 'lib/ad_localize/entities/key.rb', line 17 def plural? plural_key.present? end |
#plural_key ⇒ Object
13 14 15 |
# File 'lib/ad_localize/entities/key.rb', line 13 def plural_key @plural_key ||= compute_plural_key end |
#raw_label ⇒ Object
41 42 43 |
# File 'lib/ad_localize/entities/key.rb', line 41 def raw_label @label end |
#same_as?(key:) ⇒ Boolean
45 46 47 |
# File 'lib/ad_localize/entities/key.rb', line 45 def same_as?(key:) raw_label == key.raw_label end |
#singular? ⇒ Boolean
33 34 35 |
# File 'lib/ad_localize/entities/key.rb', line 33 def singular? !(plural? || adaptive? || info_plist?) end |