Sha256: 08a6cabb01d3227006d5f502b9a91b0e62267ff5194d73647cb47c47305e3754

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

require 'singleton'
require 'yaml'

module Tongues

  ## Provides a convenient way to edit configuration
  def self.configure(&block)
    if block_given?
      block.call(Configuration.instance)
    else
      Configuration.instance
    end
  end

  class Configuration
    include Singleton

    ## Returns the api url
    def self.api_url
      'http://ws.detectlanguage.com/0.2/detect'
    end

    ## Returns the api key
    def api_key
      @@api_key
    end

    ## Modifies the api_key
    def api_key=(key)
      @@api_key = key
    end

    ## Returns the api key
    def self.api_key
      @@api_key
    end

    ## Modifies the api_key
    def self.api_key=(key)
      @@api_key = key
    end

    ## Returns a hash of supported languages
    def self.languages
      YAML::load(File.open(File.dirname(__FILE__) + '/config.yml'))['correspondences']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tongues-0.0.12 lib/tongues/config/configuration.rb