Top Level Namespace

Defined Under Namespace

Modules: LP

Instance Method Summary collapse

Instance Method Details

#lp(anything) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lp.rb', line 7

def lp(anything)
  reset   = "\e[0m"
  red     = "\e[31m"
  green   = "\e[32m"
  yellow  = "\e[33m"
  blue    = "\e[34m"
  magenta = "\e[35m"
  cyan    = "\e[36m"

  result = anything.to_yaml
  
  result.gsub! /!ruby\/object:/, "#{blue}>>> #{reset}"
  result.gsub! /([\s\-]*:?.*?:)(.*)/, green + '\1' + reset + '\2'
  result.gsub! /([&*]\d+)/, red + '\1' + reset

  puts result
end

#lp!(anything) ⇒ Object



3
4
5
# File 'lib/lp.rb', line 3

def lp!(anything)
  puts anything.to_yaml
end

#lp?(anything) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/lp.rb', line 25

def lp?(anything)
  methods = (anything.methods - Object.methods).sort
  vars = anything.instance_variables.sort
  lp methods: methods, instance_vars: vars
end