Class: TranslationDiff::Languages::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/translation_diff/languages/set.rb

Overview

One provider's languages as captured on a date; source and target differ, so they are kept apart.

Constant Summary collapse

MACRO_ALIASES =

ISO 639-1 macrolanguage codes callers write, mapped to the ISO 639-3 individual some vendors ship instead. One-way only: a vendor listing the individual has, by definition, covered its macro; the reverse is not true.

{
  "fa" => "pes", "uz" => "uzn", "yi" => "ydd", "om" => "gaz", "qu" => "quy", "ay" => "ayr",
  "mn" => "khk", "ms" => "zsm", "lv" => "lvs", "mg" => "plt", "az" => "azj", "ps" => "pbt",
  "sw" => "swh", "ku" => "kmr", "zh" => "cmn", "ne" => "npi", "or" => "ory", "sq" => "als"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider:, captured_at:, endpoint:, source:, target:) ⇒ Set

Returns a new instance of Set.



28
29
30
31
32
33
34
35
# File 'lib/translation_diff/languages/set.rb', line 28

def initialize(provider:, captured_at:, endpoint:, source:, target:)
  @provider = provider
  @captured_at = captured_at
  @endpoint = endpoint
  @source = normalise(source)
  @target = normalise(target)
  freeze
end

Instance Attribute Details

#captured_at ⇒ Object (readonly)

Returns the value of attribute captured_at.



3
4
5
# File 'lib/translation_diff/languages/set.rb', line 3

def captured_at
  @captured_at
end

#endpoint ⇒ Object (readonly)

Returns the value of attribute endpoint.



3
4
5
# File 'lib/translation_diff/languages/set.rb', line 3

def endpoint
  @endpoint
end

#provider ⇒ Object (readonly)

Returns the value of attribute provider.



3
4
5
# File 'lib/translation_diff/languages/set.rb', line 3

def provider
  @provider
end

#source ⇒ Object (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/translation_diff/languages/set.rb', line 3

def source
  @source
end

#target ⇒ Object (readonly)

Returns the value of attribute target.



3
4
5
# File 'lib/translation_diff/languages/set.rb', line 3

def target
  @target
end

Class Method Details

.load(path) ⇒ Object



13
14
15
16
17
18
# File 'lib/translation_diff/languages/set.rb', line 13

def self.load(path)
  document = parse(path)

  new(provider: document["provider"], captured_at: document["captured_at"],
      endpoint: document["endpoint"], source: document["source"], target: document["target"])
end

Instance Method Details

#supports_source?(code) ⇒ Boolean

Returns:

  • (Boolean)


37
# File 'lib/translation_diff/languages/set.rb', line 37

def supports_source?(code) = matches?(@source, code)

#supports_target?(code) ⇒ Boolean

Returns:

  • (Boolean)


38
# File 'lib/translation_diff/languages/set.rb', line 38

def supports_target?(code) = matches?(@target, code)