Class: String

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

Instance Method Summary collapse

Instance Method Details

#commandifyObject



67
68
69
# File 'lib/room.rb', line 67

def commandify
  Regexp.compile("^" + Regexp.escape(self.gsub("_", " ")).gsub("XXX", "(.+)") + "$")
end

#underscoreObject

I actively support the inclusion of this method



72
73
74
75
76
77
78
79
# File 'lib/room.rb', line 72

def underscore
  word = dup
  word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
  word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
  word.tr!("-", "_")
  word.downcase!
  word
end

#|(o) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/room.rb', line 59

def |(o)
  if o.nil?
    self
  else
    self + "\n" + o
  end
end