Class: Irc::Bot::Config::EnumValue
Instance Attribute Summary
Attributes inherited from Value
#auth_path, #key, #manager, #order, #requires_rescan, #requires_restart, #store_default, #type, #wizard
Instance Method Summary (collapse)
- - (Object) desc
-
- (EnumValue) initialize(key, params)
constructor
A new instance of EnumValue.
- - (Object) parse(string)
- - (Object) values
Methods inherited from Value
#default, #get, #set, #set_string, #to_s, #unset
Constructor Details
- (EnumValue) initialize(key, params)
Returns a new instance of EnumValue
203 204 205 206 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 203 def initialize(key, params) super @values = params[:values] end |
Instance Method Details
- (Object) desc
220 221 222 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 220 def desc _("%{desc} [valid values are: %{values}]") % {:desc => @desc, :values => values.join(', ')} end |
- (Object) parse(string)
214 215 216 217 218 219 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 214 def parse(string) unless values.include?(string) raise ArgumentError, "invalid value #{string}, allowed values are: " + values.join(", ") end string end |
- (Object) values
207 208 209 210 211 212 213 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/config.rb', line 207 def values if @values.instance_of?(Proc) return @values.call(@manager.bot) else return @values end end |