Class: LLT::Review::Helpers::Parsing::Helper::Annotators
- Inherits:
-
Object
- Object
- LLT::Review::Helpers::Parsing::Helper::Annotators
- Defined in:
- lib/llt/review/helpers/parsing/helper/annotators.rb
Instance Method Summary collapse
- #add(annotator) ⇒ Object
-
#initialize ⇒ Annotators
constructor
A new instance of Annotators.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Annotators
Returns a new instance of Annotators.
4 5 6 |
# File 'lib/llt/review/helpers/parsing/helper/annotators.rb', line 4 def initialize @annotators = [] end |
Instance Method Details
#add(annotator) ⇒ Object
8 9 10 |
# File 'lib/llt/review/helpers/parsing/helper/annotators.rb', line 8 def add(annotator) @annotators << annotator end |
#to_s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# 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 |