Class: I18nKit::Comparer
- Inherits:
-
Object
- Object
- I18nKit::Comparer
- Defined in:
- lib/i18n_kit/comparer.rb
Instance Attribute Summary collapse
-
#documents ⇒ Object
Returns the value of attribute documents.
Instance Method Summary collapse
- #[](document_name) ⇒ Object
- #compare ⇒ Object
- #documents_to_compare(&block) ⇒ Object
-
#initialize(documents) ⇒ Comparer
constructor
A new instance of Comparer.
Constructor Details
#initialize(documents) ⇒ Comparer
Returns a new instance of Comparer.
9 10 11 |
# File 'lib/i18n_kit/comparer.rb', line 9 def initialize(documents) @documents = documents end |
Instance Attribute Details
#documents ⇒ Object
Returns the value of attribute documents.
7 8 9 |
# File 'lib/i18n_kit/comparer.rb', line 7 def documents @documents end |
Instance Method Details
#[](document_name) ⇒ Object
13 14 15 16 |
# File 'lib/i18n_kit/comparer.rb', line 13 def [](document_name) @documents.each { |doc| return doc if doc.name == document_name } nil end |
#compare ⇒ Object
18 19 20 21 22 |
# File 'lib/i18n_kit/comparer.rb', line 18 def compare documents_to_compare.each do |left, right| #puts "#{left.name} <=> #{right.name}" end end |
#documents_to_compare(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/i18n_kit/comparer.rb', line 24 def documents_to_compare(&block) docs = @documents.dup pairs = [] while base = docs.shift do docs.each do |doc| #break if doc == docs.last if block_given? yield(base, doc) else pairs << [base, doc] end end end pairs end |