Class: Translatomatic::ConverterStats

Inherits:
Object
  • Object
show all
Defined in:
lib/translatomatic/converter_stats.rb

Overview

Translation statistics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_db, from_translator) ⇒ ConverterStats

Returns a new instance of ConverterStats.



13
14
15
16
17
# File 'lib/translatomatic/converter_stats.rb', line 13

def initialize(from_db, from_translator)
  @translations = from_db + from_translator
  @from_db = from_db
  @from_translator = from_translator
end

Instance Attribute Details

#from_dbNumber (readonly)

Returns The number of translations that came from the database.

Returns:

  • (Number)

    The number of translations that came from the database.



8
9
10
# File 'lib/translatomatic/converter_stats.rb', line 8

def from_db
  @from_db
end

#from_translatorNumber (readonly)

Returns The number of translations that came from the translator.

Returns:

  • (Number)

    The number of translations that came from the translator.



11
12
13
# File 'lib/translatomatic/converter_stats.rb', line 11

def from_translator
  @from_translator
end

#translationsNumber (readonly)

Returns The total number of strings translated.

Returns:

  • (Number)

    The total number of strings translated.



5
6
7
# File 'lib/translatomatic/converter_stats.rb', line 5

def translations
  @translations
end

Instance Method Details

#+(other) ⇒ Object



19
20
21
# File 'lib/translatomatic/converter_stats.rb', line 19

def +(other)
  self.class.new(@from_db + other.from_db, @from_translator + other.from_translator)
end

#to_sObject



23
24
25
26
# File 'lib/translatomatic/converter_stats.rb', line 23

def to_s
  "Total translations: #{@translations} " +
    "(#{@from_db} from database, #{@from_translator} from translator)"
end