Module: JsonSchema::ErrorFormatter
- Defined in:
- lib/json_schema/error.rb
Class Method Summary collapse
Class Method Details
.to_list(list) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/json_schema/error.rb', line 62 def to_list(list) words_connector = ', ' two_words_connector = ' or ' last_word_connector = ', or ' length = list.length joined_list = case length when 1 list[0] when 2 "#{list[0]}#{two_words_connector}#{list[1]}" else "#{list[0...-1].join(words_connector)}#{last_word_connector}#{list[-1]}" end if joined_list[0] =~ /^[aeiou]/ "an #{joined_list}" else "a #{joined_list}" end end |