Class: GamesAndRpgParadise::Mud::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/mud/base/base.rb

Direct Known Subclasses

Client, Continent, MonsterFactory, NameGenerator, Shell

Instance Method Summary collapse

Instance Method Details

#find_adverb_for(i) ⇒ Object

#

find_adverb_for

#


64
65
66
# File 'lib/games_and_rpg_paradise/mud/base/base.rb', line 64

def find_adverb_for(i)
  ::GamesAndRpgParadise::Mud::Adverbs.find_adverb_for(i)
end

#lang_wnum(i) ⇒ Object

#

lang_wnum

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/games_and_rpg_paradise/mud/base/base.rb', line 14

def lang_wnum(i)
  case i
  when 1
    'one'
  when 2
    'two'
  when 3
    'three'
  when 4
    'four'
  when 5
    'five'
  when 6
    'six'
  when 7
    'seven'
  end
end

#sentence(i = '') ⇒ Object

#

sentence

Formulate a proper sentence. A proper sentence will terminate with a colon.

#


39
40
41
42
# File 'lib/games_and_rpg_paradise/mud/base/base.rb', line 39

def sentence(i = '')
  i << '.' unless i.end_with? '.'
  e i
end

#word_wrap(i, max_line_width = 80, optional_padding = '') ⇒ Object

#

word_wrap

#


47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/games_and_rpg_paradise/mud/base/base.rb', line 47

def word_wrap(
    i, max_line_width = 80, optional_padding = ''
  )
  # ========================================================================= #
  # We need to work on each individual entry.
  # ========================================================================= #
  your_text = i.split("\n").map {|line|
    line.size > max_line_width ? line.gsub(/(.{1,#{max_line_width}})(\s+|$)/,
      optional_padding+"\\1\n").chomp : line 
  }
  your_text * "\n"
end