Module: Sober

Defined in:
lib/sober.rb,
lib/sober/version.rb

Defined Under Namespace

Classes: Gender, Name

Constant Summary collapse

VERSION =
'0.0.2'

Class Method Summary collapse

Class Method Details

.aObject



12
# File 'lib/sober.rb', line 12

def self.a; ADJECTIVES.sample; end

.adObject



13
# File 'lib/sober.rb', line 13

def self.ad; ADVERBS.sample; end

.arObject



14
# File 'lib/sober.rb', line 14

def self.ar; ARTICLES.sample; end

.cObject



17
# File 'lib/sober.rb', line 17

def self.c; CONJUNCTIONS.sample; end

.lvObject



11
# File 'lib/sober.rb', line 11

def self.lv; LONG_VERBS.sample; end

.nObject



8
# File 'lib/sober.rb', line 8

def self.n; NOUNS.sample; end

.paragraph(type = :medium) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/sober.rb', line 45

def self.paragraph(type = :medium)
  if type == :short
    n = rand(2..4)
  elsif type == :long
    n = rand(10..15)
  else
    n = rand(5..9)
  end
  self.sentences(n)
end

.paragraphs(n = 3) ⇒ Object



56
57
58
59
60
# File 'lib/sober.rb', line 56

def self.paragraphs(n = 3)
  block = []
  n.times { block << self.paragraph }
  block.join("\n\n")
end

.pcnObject



18
# File 'lib/sober.rb', line 18

def self.pcn; PUNCTUATION.sample; end

.pnObject



9
# File 'lib/sober.rb', line 9

def self.pn; PROPER_NOUNS.sample; end

.ppObject



15
# File 'lib/sober.rb', line 15

def self.pp; PREPOSITIONS.sample; end

.prObject



16
# File 'lib/sober.rb', line 16

def self.pr; PRONOUNS.sample; end

.sentence(type = :medium) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sober.rb', line 20

def self.sentence(type = :medium)
  #case when
  extend ShortClauses
  return sentencify(self.short_clauses.first) if type == :short

  extend MediumClauses
  return sentencify(self.medium_clauses.first) if type == :medium

  extend LongClauses
  return sentencify(self.long_clauses.sample) if type == :long

  extend PunctuatedClauses

  #for paragraphs and n number of sentences
  if type.is_a?(Fixnum)
    n = type
    paragraph_array = [self.short_clauses,self.medium_clauses,self.punctuated_clauses,self.long_clauses].flatten(1).sample(n)
    return paragraph_array.map {|sentence_array| sentencify(sentence_array)}.join(' ')
  end
end

.sentences(n = 3) ⇒ Object



41
42
43
# File 'lib/sober.rb', line 41

def self.sentences(n = 3)
  self.sentence(n)
end

.vObject



10
# File 'lib/sober.rb', line 10

def self.v; VERBS.sample; end