Class: Pronto::Formatter::GithubStatusFormatter::Sentence

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/formatter/github_status_formatter/sentence.rb

Instance Method Summary collapse

Constructor Details

#initialize(words) ⇒ Sentence

Returns a new instance of Sentence.



5
6
7
# File 'lib/pronto/formatter/github_status_formatter/sentence.rb', line 5

def initialize(words)
  @words = words
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pronto/formatter/github_status_formatter/sentence.rb', line 9

def to_s
  case words.size
  when 0
    ''
  when 1
    words[0].to_s.dup
  when 2
    "#{words[0]}#{WORD_CONNECTORS[:two_words_connector]}#{words[1]}"
  else
    to_oxford_comma_sentence
  end
end