Module: TerminalMarkup::InstanceMethods

Included in:
Object, String
Defined in:
lib/terminal_markup.rb

Instance Method Summary collapse

Instance Method Details

#escapeObject

for printing to console with escape codes intact



78
79
80
# File 'lib/terminal_markup.rb', line 78

def escape
  eval '"'+ to_s.gsub(/\"/,'\"') + '"'
end

#with_escape_code(code) ⇒ Object

returns the string wrapped in the supplied escape code



73
74
75
# File 'lib/terminal_markup.rb', line 73

def with_escape_code(code)
  "\\e[#{code}m#{self.to_s}\\e[0m"
end