Public instance methods
_pretty_print
(array)
[show source]
# File lib/spec/matchers/pretty.rb, line 21 def _pretty_print(array) result = "" array.each_with_index do |item, index| if index < (array.length - 2) result << "#{item.inspect}, " elsif index < (array.length - 1) result << "#{item.inspect} and " else result << "#{item.inspect}" end end result end
split_words
(sym)
[show source]
# File lib/spec/matchers/pretty.rb, line 4 def split_words(sym) sym.to_s.gsub(/_/,' ') end
to_sentence
(words)
[show source]
# File lib/spec/matchers/pretty.rb, line 8 def to_sentence(words) case words.length when 0 "" when 1 " #{words[0]}" when 2 " #{words[0]} and #{words[1]}" else " #{words[0...-1].join(', ')}, and #{words[-1]}" end end