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

Inherits:
Value show all
Defined in:
/home/apoc/projects/ruby/rbot/lib/rbot/config.rb

Instance Attribute Summary

Attributes inherited from Value

#auth_path, #desc, #key, #manager, #order, #requires_rescan, #requires_restart, #store_default, #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

- (Object) get



133
134
135
136
137
138
139
140
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 133

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

- (Object) parse(string)

Raises:

  • (ArgumentError)


125
126
127
128
129
130
131
132
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 125

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