Module: FillerText

Defined in:
lib/fillertext.rb,
lib/fillertext/integer.rb,
lib/fillertext/version.rb,
lib/fillertext/fillertext.rb,
lib/fillertext/styles/lorem.rb,
lib/fillertext/styles/yinzer.rb,
lib/fillertext/styles/hipster.rb,
lib/fillertext/styles/mike_lange.rb

Overview

Helper module to choose styles

Defined Under Namespace

Modules: Integer, Style

Constant Summary collapse

VERSION =
"0.3.5"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.numObject

Returns the value of attribute num.



8
9
10
# File 'lib/fillertext/fillertext.rb', line 8

def num
  @num
end

.styleObject

Returns the value of attribute style.



8
9
10
# File 'lib/fillertext/fillertext.rb', line 8

def style
  @style
end

Class Method Details

.bytes(num = nil) ⇒ Object



13
14
15
16
# File 'lib/fillertext/fillertext.rb', line 13

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

.characters(num = nil) ⇒ Object



18
19
20
# File 'lib/fillertext/fillertext.rb', line 18

def self.characters(num = nil)
  bytes(num)
end

.paragraphs(num = nil) ⇒ Object



32
33
34
35
# File 'lib/fillertext/fillertext.rb', line 32

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

.sentences(num = nil) ⇒ Object



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

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

.words(num = nil) ⇒ Object



22
23
24
25
# File 'lib/fillertext/fillertext.rb', line 22

def self.words(num = nil)
  num ||= self.num
  style.text.split[0, num].join(" ").gsub(/[^\w\s]/, "")
end