Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/drakkon/lib/shims.rb,
lib/drakkon/lib/pastel.rb

Overview

Monkey Patch

Instance Method Summary collapse

Instance Method Details

#numeric?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'lib/drakkon/lib/shims.rb', line 3

def numeric?
  !Float(self).nil?
rescue StandardError
  false
end

#pastel(*args) ⇒ Object



20
21
22
# File 'lib/drakkon/lib/pastel.rb', line 20

def pastel(*args)
  Drakkon::Color.decorate(args.unshift(self))
end

#snake_caseObject



28
29
30
31
32
33
34
# File 'lib/drakkon/lib/pastel.rb', line 28

def snake_case
  return downcase if match(/\A[A-Z]+\z/)

  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z])([A-Z])/, '\1_\2')
    .downcase
end

#unpastelObject



24
25
26
# File 'lib/drakkon/lib/pastel.rb', line 24

def unpastel
  Drakkon::Color.pastel.strip self
end