Class: Irc::Bot::Config::IntegerValue

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



150
151
152
153
154
155
156
157
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 150

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

- (Object) parse(string)

Raises:

  • (ArgumentError)


144
145
146
147
148
149
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 144

def parse(string)
  return 1 if string == "true"
  return 0 if string == "false"
  raise ArgumentError, "not an integer: #{string}" unless string =~ /^-?\d+$/
  string.to_i
end