Class: AdLocalize::Entities::Key

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/ad_localize/entities/key.rb', line 21

def adaptive?
  adaptive_key.present?
end

#adaptive_keyObject



25
26
27
# File 'lib/ad_localize/entities/key.rb', line 25

def adaptive_key
  @adaptive_key ||= compute_adaptive_key
end

#info_plist?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ad_localize/entities/key.rb', line 29

def info_plist?
  @label.match(INFO_PLIST_KEY_REGEXP).present?
end

#labelObject



37
38
39
# File 'lib/ad_localize/entities/key.rb', line 37

def label
  compute_label.strip
end

#plural?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ad_localize/entities/key.rb', line 17

def plural?
  plural_key.present?
end

#plural_keyObject



13
14
15
# File 'lib/ad_localize/entities/key.rb', line 13

def plural_key
  @plural_key ||= compute_plural_key
end

#raw_labelObject



41
42
43
# File 'lib/ad_localize/entities/key.rb', line 41

def raw_label
  @label
end

#same_as?(key:) ⇒ Boolean

Returns:

  • (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

Returns:

  • (Boolean)


33
34
35
# File 'lib/ad_localize/entities/key.rb', line 33

def singular?
  !(plural? || adaptive? || info_plist?)
end