Class: Irc::Bot::Config::BooleanValue

Inherits:
Value show all
Defined in:
lib/rbot/config.rb

Instance Attribute Summary

Attributes inherited from Value

#auth_path, #desc, #key, #manager, #order, #requires_rescan, #requires_restart, #type, #wizard

Instance Method Summary collapse

Methods inherited from Value

#default, #initialize, #set, #set_string, #to_s, #unset

Constructor Details

This class inherits a constructor from Irc::Bot::Config::Value

Instance Method Details

#getObject



131
132
133
134
135
136
137
138
# File 'lib/rbot/config.rb', line 131

def get
  r = super
  if r.kind_of?(Integer)
    return r != 0
  else
    return r
  end
end

#parse(string) ⇒ Object

Raises:

  • (ArgumentError)


123
124
125
126
127
128
129
130
# File 'lib/rbot/config.rb', line 123

def parse(string)
  return true if string == "true"
  return false if string == "false"
  if string =~ /^-?\d+$/
    return string.to_i != 0
  end
  raise ArgumentError, "#{string} does not match either 'true' or 'false', and it's not an integer either"
end