Class: Corrector::Base

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/corrector/base.rb

Overview

Stores a list of translations (words or phrases).

Direct Known Subclasses

Phrase, Prefix, Word

Class Method Summary collapse

Class Method Details

.scan(value) ⇒ Object

Scans the dictionary for source string translation. Returns the source if no translation found.

Params:

value

a string to be scanned

Returns a translation or the source itself if no translation found.

Examples:

Base.scan "КИЛОМЕТР" # => "КМ"


32
33
34
# File 'app/models/corrector/base.rb', line 32

def self.scan(value)
  where(from: value).first.try(:to) || value
end