class Irc::Bot::Config::ArrayValue
Public Class Methods
new(key, params)
click to toggle source
Calls superclass method
Irc::Bot::Config::Value::new
# File lib/rbot/config.rb, line 168 def initialize(key, params) super @validate_item = params[:validate_item] @validate ||= Proc.new do |v| !v.find { |i| !validate_item(i) } end end
Public Instance Methods
add(val)
click to toggle source
# File lib/rbot/config.rb, line 186 def add(val) newval = self.get.dup unless newval.include? val newval << val validate_item(val) or raise ArgumentError, "invalid item: #{val}" validate(newval) or raise ArgumentError, "invalid value: #{newval.inspect}" set(newval) end end
parse(string)
click to toggle source
# File lib/rbot/config.rb, line 180 def parse(string) string.split(/,\s+/) end
rm(val)
click to toggle source
# File lib/rbot/config.rb, line 195 def rm(val) curval = self.get raise ArgumentError, "value #{val} not present" unless curval.include?(val) set(curval - [val]) end
to_s()
click to toggle source
# File lib/rbot/config.rb, line 183 def to_s get.join(", ") end
validate_item(item)
click to toggle source
# File lib/rbot/config.rb, line 176 def validate_item(item) validate(item, @validate_item) end