class AdLocalize::Entities::Key

Constants

ADAPTIVE_KEY_REGEXP
INFO_PLIST_KEY_REGEXP

see developer.apple.com/documentation/bundleresources/information_property_list

PLURAL_KEY_REGEXP

Public Class Methods

new(label:) click to toggle source
# File lib/ad_localize/entities/key.rb, line 9
def initialize(label:)
  @label = label
end

Public Instance Methods

==(o) click to toggle source
# File lib/ad_localize/entities/key.rb, line 49
def ==(o)
  o.class == self.class &&
  o.raw_label == raw_label
end
adaptive?() click to toggle source
# File lib/ad_localize/entities/key.rb, line 21
def adaptive?
  adaptive_key.present?
end
adaptive_key() click to toggle source
# File lib/ad_localize/entities/key.rb, line 25
def adaptive_key
  @adaptive_key ||= compute_adaptive_key
end
info_plist?() click to toggle source
# File lib/ad_localize/entities/key.rb, line 29
def info_plist?
  @label.match(INFO_PLIST_KEY_REGEXP).present?
end
label() click to toggle source
# File lib/ad_localize/entities/key.rb, line 37
def label
  compute_label.strip
end
plural?() click to toggle source
# File lib/ad_localize/entities/key.rb, line 17
def plural?
  plural_key.present?
end
plural_key() click to toggle source
# File lib/ad_localize/entities/key.rb, line 13
def plural_key
  @plural_key ||= compute_plural_key
end
raw_label() click to toggle source
# File lib/ad_localize/entities/key.rb, line 41
def raw_label
  @label
end
same_as?(key:) click to toggle source
# File lib/ad_localize/entities/key.rb, line 45
def same_as?(key:)
  raw_label == key.raw_label
end
singular?() click to toggle source
# File lib/ad_localize/entities/key.rb, line 33
def singular?
  !(plural? || adaptive? || info_plist?)
end

Private Instance Methods

compute_adaptive_key() click to toggle source
# File lib/ad_localize/entities/key.rb, line 72
def compute_adaptive_key
  match = @label.match(ADAPTIVE_KEY_REGEXP)
  return unless match
  match.captures.first
end
compute_label() click to toggle source
# File lib/ad_localize/entities/key.rb, line 56
def compute_label
  if plural?
    @label.gsub(PLURAL_KEY_REGEXP, '')
  elsif adaptive?
    @label.gsub(ADAPTIVE_KEY_REGEXP, '')
  else
    @label
  end
end
compute_plural_key() click to toggle source
# File lib/ad_localize/entities/key.rb, line 66
def compute_plural_key
  match = @label.match(PLURAL_KEY_REGEXP)
  return unless match
  match.captures.first
end