Sha256: 663a89a5021362a03ba5b5f05b122fed42ddc9ccdbf93cbdea724df7c23a133d

Contents?: true

Size: 793 Bytes

Versions: 8

Compression:

Stored size: 793 Bytes

Contents

module SlackRubyBot
  module Config
    extend self

    attr_accessor :token
    attr_accessor :url
    attr_accessor :aliases
    attr_accessor :user
    attr_accessor :user_id
    attr_accessor :team
    attr_accessor :team_id
    attr_accessor :allow_message_loops
    attr_accessor :send_gifs

    def allow_message_loops?
      allow_message_loops
    end

    def send_gifs?
      v = boolean_from_env('SLACK_RUBY_BOT_SEND_GIFS')
      v.nil? ? (send_gifs.nil? || send_gifs) : v
    end

    private

    def boolean_from_env(key)
      value = ENV[key]
      case value
      when nil
        nil
      when 0, 'false', 'no'
        false
      when 1, 'true', 'yes'
        true
      else
        fail ArgumentError, "Invalid value for #{key}: #{value}."
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
slack-ruby-bot-bhe-0.5.5.3 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.6.0 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.5 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.4 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.3 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.2 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.1 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.5.0 lib/slack-ruby-bot/config.rb