Sha256: f7b50a6c33381693ea56274a044711394d3805b5a9d8fa59ae18b3ef38e462b6

Contents?: true

Size: 621 Bytes

Versions: 4

Compression:

Stored size: 621 Bytes

Contents

module Ting
  class Converter
    include Procable

    attr_reader :from_conv, :from_tone, :to_conv, :to_tone

    def initialize(from, from_tone, to, to_tone)
      @from_conv, @from_tone, @to_conv, @to_tone = from, from_tone, to, to_tone
    end

    def reader
      @reader ||= Reader.new(from_conv, from_tone)
    end

    def writer
      @writer ||= Writer.new(to_conv, to_tone)
    end

    def convert(str)
      writer.unparse reader.parse(str)
    end

    def to(to, to_tone)
      Converter.new(self.from_conv, self.from_tone, to, to_tone)
    end

    alias :<< :convert
    alias :call :convert
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ting-0.12.0 lib/ting/converter.rb
ting-0.11.0 lib/ting/converter.rb
ting-0.10.0 lib/ting/converter.rb
ting-0.9.0 lib/ting/converter.rb