# File lib/bindata/choice.rb, line 135 def choices_as_hash(choices) if choices.respond_to?(:to_ary) key_array_by_index(choices.to_ary) else choices end end
# File lib/bindata/choice.rb, line 151 def ensure_valid_keys(choices) if choices.key?(nil) raise ArgumentError, ":choices hash may not have nil key" end if choices.keys.detect { |key| key.is_a?(Symbol) && key != :default } raise ArgumentError, ":choices hash may not have symbols for keys" end end
# File lib/bindata/choice.rb, line 143 def key_array_by_index(array) result = {} array.each_with_index do |el, i| result[i] = el unless el.nil? end result end