Sha256: 785f1a7db9354dcd78aca4345f85bcc338979b06fc280b8567157632a6e3bdca

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents


module Stella
  
  class Text
    class Resource
      require 'yaml'
      
      attr_reader :lang, :country, :encoding
      attr_reader :messages, :path
      
      def initialize(path, lang)
        @path = path
        @lang = lang
        @messages = {}
        load_resource
      end
      
      def path
        File.join(@path, "#{@lang}.yaml")
      end
      
      def load_resource
        return @messages unless @messages.empty?
        Stella::LOGGER.debug("LOADING #{path}")
        raise UnsupportedLanguage unless File.exists?(path)
        @messages = YAML.load_file(path)
      end
      
      def messages
        @messages
      end
        alias :message :messages
        alias :error :messages
      
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stella-0.3.2 lib/stella/text/resource.rb
stella-0.5.3 lib/stella/text/resource.rb
stella-0.5.1 lib/stella/text/resource.rb