Module: Rubeechat::Config

Extended by:
Weechat
Includes:
Weechat
Defined in:
lib/rubeechat/config.rb

Defined Under Namespace

Classes: GenericOptionError, OptionNotFoundError

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



9
10
11
12
13
# File 'lib/rubeechat/config.rb', line 9

def self.[](key)
  key = key.to_s
  return nil unless has_key?(key)
  config_get_plugin(key)
end

.[]=(key, value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubeechat/config.rb', line 15

def self.[]=(key,value)
  case config_set_plugin(key.to_s, value.to_s)
  when WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
    value
  when WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
    value
  when WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND
    raise OptionNotFoundError, key.to_s
  when WEECHAT_CONFIG_OPTION_SET_ERROR
    raise GenericOptionError, key.to_s
  end
end

.has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rubeechat/config.rb', line 28

def self.has_key?(key)
  config_is_set_plugin(key) > 0
end