Sha256: bd242a338b70bafdfe9606ac25b25cc6841aa79a4b1eefb510c84369a7fe0cd6

Contents?: true

Size: 395 Bytes

Versions: 2

Compression:

Stored size: 395 Bytes

Contents

# frozen_string_literal: true

module Diachronr
  # rules for rewriting character variations and digraphs
  class Rewrite
    attr_accessor :from, :to

    def initialize(rewrite)
      @from, @to = rewrite.split '|'
    end # initialize

    def apply(target)
      target.gsub @from, @to
    end # apply

    def reverse(target)
      target.gsub @to, @from
    end
  end # class
end # module

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
diachronr-1.1.0 lib/diachronr/rewrite.rb
diachronr-1.0.0 lib/diachronr/rewrite.rb