Class: Troo::Sentence
- Inherits:
-
Object
- Object
- Troo::Sentence
- Defined in:
- lib/troo/presentation/sentence.rb
Class Method Summary collapse
Instance Method Summary collapse
Constructor Details
#initialize(elements, label) ⇒ Troo::Sentence
15 16 17 |
# File 'lib/troo/presentation/sentence.rb', line 15 def initialize(elements, label) @elements, @label = elements, label end |
Class Method Details
.construct(elements, label = 'elements') ⇒ String
7 8 9 |
# File 'lib/troo/presentation/sentence.rb', line 7 def construct(elements, label = 'elements') new(elements, label).construct end |
Instance Method Details
#construct ⇒ String
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/troo/presentation/sentence.rb', line 20 def construct if one? first elsif two? elements.join(' and ') elsif many? [but_last, last].join(' and ') else "No #{label} have been assigned." end end |