class Translatomatic::Translation::Stats

Translation statistics

Attributes

from_db[R]

@return [Number] The number of translations that came from the database.

from_provider[R]

@return [Number] The number of translations that came from the provider.

translations[R]

@return [Array<Result>] A list of all translations

untranslated[R]

@return [Number] The number of untranslated strings

Public Class Methods

new(translations = []) click to toggle source
# File lib/translatomatic/translation/stats.rb, line 29
def initialize(translations = [])
  @translations = list = translations
  @from_db = list.count { |i| i.from_database && i.result }
  @from_provider = list.count { |i| !i.from_database && i.result }
  @untranslated = list.count { |i| i.result.nil? }
end

Public Instance Methods

+(other) click to toggle source

Combine stats with another object @param other [Stats] Another stats object @return [Stats] The result of adding this to other

# File lib/translatomatic/translation/stats.rb, line 22
def +(other)
  raise "expected Stats, got #{other.class}" unless other.is_a?(Stats)
  Stats.new(translations + other.translations)
end

Private Instance Methods

to_s() click to toggle source
# File lib/translatomatic/translation/stats.rb, line 36
def to_s
  key = 'translator.total_translations'
  t(key, total: @translations.length,
         from_db: @from_db, from_provider: @from_provider,
         untranslated: @untranslated)
end