Module: Lofis
- Defined in:
- lib/lofis.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.load_file(file) ⇒ Object
13 14 15 |
# File 'lib/lofis.rb', line 13 def self.load_file(file) @mapping = YAML.load_file(file)['umlaut'].map { |r,s| [Regexp.new(s.map { |c| Regexp.escape(c) }.join('|')), r] } end |
.mapping ⇒ Object
8 9 10 11 |
# File 'lib/lofis.rb', line 8 def self.mapping @mapping ||= load_file(File.join(File.dirname(__FILE__), '..', 'lofis.yml')) @mapping || raise(Error, 'no lofis file loaded') end |
.to_sortable(s) ⇒ Object
17 18 19 20 21 |
# File 'lib/lofis.rb', line 17 def self.to_sortable(s) mapping.inject(s) do |g,(s,r)| g.gsub(s, r) end end |
Instance Method Details
#to_sortable ⇒ Object
23 24 25 |
# File 'lib/lofis.rb', line 23 def to_sortable @_lofis_sortable ||= Lofis.to_sortable(self) end |