class Pronto::Formatter::GithubStatusFormatter::Sentence

Constants

WORD_CONNECTORS

Attributes

words[R]

Public Class Methods

new(words) click to toggle source
# File lib/pronto/formatter/github_status_formatter/sentence.rb, line 5
def initialize(words)
  @words = words
end

Public Instance Methods

to_s() click to toggle source
# 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

Private Instance Methods

to_oxford_comma_sentence() click to toggle source
# File lib/pronto/formatter/github_status_formatter/sentence.rb, line 34
def to_oxford_comma_sentence
  "#{words[0...-1].join(WORD_CONNECTORS[:words_connector])}"\
    "#{WORD_CONNECTORS[:last_word_connector]}"\
    "#{words[-1]}"
end