Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/midori/core_ext/string.rb,
lib/midori/env.rb

Overview

Meta-programming String for Syntactic Sugars

Instance Method Summary collapse

Instance Method Details

#blueObject

color the string with blue color



26
27
28
# File 'lib/midori/core_ext/string.rb', line 26

def blue
  colorize(34)
end

#colorize(color_code) ⇒ String

Returns colored string.

Parameters:

  • color_code (Integer)

    ANSI color code

Returns:



6
7
8
# File 'lib/midori/core_ext/string.rb', line 6

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end

#development?TrueClass | FalseClass

Returns if string is equal to development.

Returns:

  • (TrueClass | FalseClass)

    if string is equal to development



15
16
17
# File 'lib/midori/env.rb', line 15

def development?
  self == 'development'
end

#greenObject

color the string with green color



16
17
18
# File 'lib/midori/core_ext/string.rb', line 16

def green
  colorize(32)
end

#production?TrueClass | FalseClass

Returns if string is equal to production.

Returns:

  • (TrueClass | FalseClass)

    if string is equal to production



10
11
12
# File 'lib/midori/env.rb', line 10

def production?
  self == 'production'
end

#redObject

color the string with red color



11
12
13
# File 'lib/midori/core_ext/string.rb', line 11

def red
  colorize(31)
end

#yellowObject

color the string with yellow color



21
22
23
# File 'lib/midori/core_ext/string.rb', line 21

def yellow
  colorize(33)
end