Class: FillerText::FillerText

Inherits:
Object
  • Object
show all
Defined in:
lib/fillertext/fillertext.rb

Constant Summary collapse

@@style =
Style::LoremIpsum
@@num =
0

Class Method Summary collapse

Class Method Details

.bytes(n = nil) ⇒ Object



44
45
46
47
# File 'lib/fillertext/fillertext.rb', line 44

def self.bytes(n=nil)
  n ||= self.n
  self.style.text[0,n]
end

.characters(n = nil) ⇒ Object



49
50
51
52
# File 'lib/fillertext/fillertext.rb', line 49

def self.characters(n=nil)
  #same thing for now
  self.bytes(n)
end

.nObject



40
41
42
# File 'lib/fillertext/fillertext.rb', line 40

def self.n
  @@num
end

.n=(n) ⇒ Object



36
37
38
# File 'lib/fillertext/fillertext.rb', line 36

def self.n=(n)
  @@num = n
end

.paragraphs(n = nil) ⇒ Object



65
66
67
68
# File 'lib/fillertext/fillertext.rb', line 65

def self.paragraphs(n=nil)
  n ||= self.n
  self.style.text.split("\n").slice(0,n).join("\n")
end

.sentences(n = nil) ⇒ Object



60
61
62
63
# File 'lib/fillertext/fillertext.rb', line 60

def self.sentences(n=nil)
  n ||= self.n
  self.style.text.split('.').slice(0,n).join(". ")
end

.styleObject



30
31
32
# File 'lib/fillertext/fillertext.rb', line 30

def self.style
  @@style
end

.style=(style) ⇒ Object



26
27
28
# File 'lib/fillertext/fillertext.rb', line 26

def self.style=(style)
  @@style = style
end

.words(n = nil) ⇒ Object



54
55
56
57
58
# File 'lib/fillertext/fillertext.rb', line 54

def self.words(n=nil)
  n ||= self.n
  #the idea here is to find the nth space and return everything before it
  self.style.text.split[0,n].join(" ").gsub(/[^\w\s]/,'')
end