Sha256: 11ba94da67c4bcdf7bfe267e6903bc2de9c95748cdbeea0646ba3ffd93b98151

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

# -*- encoding: utf-8 -*-

module Wookie::Dialect

  # Basic class to be inherited from, when building new dialects.
  # Though currently not implemented, a future version of the {Wookie::Translator}
  # may check, if any given dialect is actually a subclass of {Wookie::Dialect::Base}.
  class Base

    # Keeps track of available subclasses.
    # @param [Class] sub The subclass.
    def self.inherited(sub)
      @@subclasses ||= []
      @@subclasses << sub
    end

    # Returns the known subclasses
    # @return [Array] A list of known subclasses.
    def self.subclasses
      @@subclasses
    end

    # Translates an english string to wookiespeack.
    #
    # @note Must be implemented in the sub class.
    # @param [String] The string to be translated.
    # @return [String] The translation.
    # @raise NotImplementedError
    def to_wookie(str)
      raise NotImplementedError
    end

    # Translates a wookiespeak string to english.
    #
    # @note Must be implemented in the sub class.
    # @param [String] The string to be translated.
    # @return [String] The translation.
    # @raise NotImplementedError
    def from_wookie(str)
      raise NotImplementedError
    end
  end

  autoload :Simple, 'wookie/dialects/simple'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wookie-translator-0.1.1 lib/wookie/dialect.rb
wookie-translator-0.1.0 lib/wookie/dialect.rb