Class: String

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

Instance Method Summary collapse

Instance Method Details

#capitalizeObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dunmanifestin/string.rb', line 22

def capitalize
  case_mapping = {
    "ä" => "Ä",
    "ö" => "Ö",
  }
  
  s = original_capitalize
  case_mapping.each_pair do |lower, upper|
    s.gsub!(%r{^#{lower}}, upper)
  end
  s
end

#is_name?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/dunmanifestin/string.rb', line 4

def is_name?
  self[0] == '|'
end

#listerpolate(universe) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dunmanifestin/string.rb', line 8

def listerpolate universe
  body = self
  
  while body.match(/\[\w+\]/) do
    slug = body.match(/\[\w+\]/).to_s
    phrase = universe.send(slug.gsub('[', '').gsub(']', ''))
    body = body.sub(slug, phrase)
  end

  body
end

#original_capitalizeObject



20
# File 'lib/dunmanifestin/string.rb', line 20

alias :original_capitalize :capitalize

#split_on_newlines_and_stripObject



35
36
37
# File 'lib/dunmanifestin/string.rb', line 35

def split_on_newlines_and_strip
  split(/\s*\n\s*/).reject(&:empty?)
end