class LLT::Review::Helpers::Parsing::Helper::Annotators

Public Class Methods

new() click to toggle source
# File lib/llt/review/helpers/parsing/helper/annotators.rb, line 4
def initialize
  @annotators = []
end

Public Instance Methods

add(annotator) click to toggle source
# File lib/llt/review/helpers/parsing/helper/annotators.rb, line 8
def add(annotator)
  @annotators << annotator
end
to_s() click to toggle source
# File lib/llt/review/helpers/parsing/helper/annotators.rb, line 12
def to_s
  meth = :name_and_short_to_s
  case @annotators.length
  when 0 then "unknown annotators"
  when 1 then @annotators.first.send(meth)
  when 2 then @annotators.map { |a| a.send(meth) }.join(' and ')
  else
    with_punct = @annotators[0..-2].map { |a| a.send(meth) }.join(', ')
    "#{with_punct} and #{@annotators.last.send(meth)}"
  end
end