Class: GetText::Tools::MsgMerge::FuzzyEntryFinder

### Home Classes Methods

### In Files

- lib/gettext/tools/msgmerge.rb

### Parent

Object

### Methods

- ::new
- #find

### Class/Module Index

Quicksearch

- GetText
- GetText::ClassInfo
- GetText::ErbParser
- GetText::GladeParser
- GetText::LocalePath
- GetText::MO
- GetText::MO::HeaderRev1
- GetText::MO::InvalidFormat
- GetText::NoboundTextDomainError
- GetText::PO
- GetText::PO::NonExistentEntryError
- GetText::POEntry
- GetText::POEntry::Formatter
- GetText::POEntry::InvalidTypeError
- GetText::POEntry::NoMsgctxtError
- GetText::POEntry::NoMsgidError
- GetText::POEntry::NoMsgidPluralError
- GetText::POEntryForRubyParser
- GetText::POFormat
- GetText::POParser
- GetText::ParseError
- GetText::RubyParser
- GetText::TextDomain
- GetText::TextDomainGroup
- GetText::TextDomainManager
- GetText::Tools
- GetText::Tools::MsgCat
- GetText::Tools::MsgCat::Config
- GetText::Tools::MsgCat::Merger
- GetText::Tools::MsgInit
- GetText::Tools::MsgInit::ArgumentError
- GetText::Tools::MsgInit::Error
- GetText::Tools::MsgInit::ValidationError
- GetText::Tools::MsgMerge
- GetText::Tools::MsgMerge::Config
- GetText::Tools::MsgMerge::FuzzyEntryFinder
- GetText::Tools::MsgMerge::Merger
- GetText::Tools::Task
- GetText::Tools::Task::Error
- GetText::Tools::Task::Path
- GetText::Tools::Task::ValidationError
- GetText::Tools::XGetText

No matching classes.

# GetText::Tools::MsgMerge::FuzzyEntryFinder

@private

### Constants

MAX_FUZZY_DISTANCE
MAX_N_CHARACTERS_DIFFERENCE

### Public Class Methods

new(entries) click to toggle source

    # File lib/gettext/tools/msgmerge.rb, line 213
    def initialize(entries)
      @entries = entries
      @target_entries = {}
    end

### Public Instance Methods

find(msgid, msgctxt) click to toggle source

    # File lib/gettext/tools/msgmerge.rb, line 219
    def find(msgid, msgctxt)
      return nil if msgid == :last
      min_distance_entry = nil
      min_distance = MAX_FUZZY_DISTANCE

      target_entries = extract_target_entries(msgctxt)
      target_entries.each do |entry|
        distance = compute_distance(entry.msgid, msgid)
        next if distance.nil?
        if min_distance > distance
          min_distance = distance
          min_distance_entry = entry
        end
      end

      min_distance_entry
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.