Sha256: d0fb18c1d03797d865a4dec73163cfc48df5793b148b670c06efa1eb579d6bb3

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents


module Stella
  
  class Text
    class Resource
      require 'yaml'
      
      attr_reader :lang, :country, :encoding
      
      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

2 entries across 2 versions & 2 rubygems

Version Path
solutious-stella-0.5.5 lib/stella/text/resource.rb
stella-0.5.5 lib/stella/text/resource.rb