Method: AnswersHelper.free_indicator_of
- Defined in:
- lib/util/answers_helper.rb
.free_indicator_of(answer, opts = {}) ⇒ Object
Gets first free indicator for ‘answer` which isn’t used by ‘used_indicators`.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/util/answers_helper.rb', line 27 def self.free_indicator_of answer, opts={} opts = {:used_indicators => []}.merge(opts) used_indicators = opts[:used_indicators] first_chars = 1 loop do indicator = answer.indicator(first_chars) if used_indicators.include? indicator first_chars += 1 redo # next try else return indicator end end end |