class Compendium::ParamWithChoices
Public Class Methods
new(obj, choices)
click to toggle source
Calls superclass method
# File lib/compendium/param_types.rb, line 33 def initialize(obj, choices) @choices = choices if @choices.respond_to?(:call) # If given a proc, defer determining values until later. index = obj else index = obj.numeric? ? obj.to_i : @choices.index(obj) raise IndexError if (!obj.nil? && index.nil?) || index.to_i.abs > @choices.length - 1 end super(index) end
Public Instance Methods
value()
click to toggle source
# File lib/compendium/param_types.rb, line 47 def value @choices[self] end