mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Document Pry::Helpers::Color …
This commit is contained in:
parent
dce86f8b44
commit
495e00caa7
1 changed files with 15 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
class Pry
|
||||
module Helpers
|
||||
|
||||
# The methods defined on {Color} are available to custom commands.
|
||||
module Color
|
||||
|
||||
extend self
|
||||
|
@ -31,14 +32,27 @@ class Pry
|
|||
alias_method :grey, :bright_black
|
||||
alias_method :gray, :bright_black
|
||||
|
||||
|
||||
# Remove any color codes from _text_.
|
||||
#
|
||||
# @param [String, #to_s] text
|
||||
# @return [String] _text_ stripped of any color codes.
|
||||
def strip_color text
|
||||
text.gsub /\e\[.*?(\d)+m/, ''
|
||||
text.to_s.gsub /\e\[.*?(\d)+m/, ''
|
||||
end
|
||||
|
||||
# Returns _text_ as bold text for use on a terminal.
|
||||
# _Pry.color_ must be true for this method to perform any transformations.
|
||||
#
|
||||
# @param [String, #to_s] text
|
||||
# @return [String] _text_
|
||||
def bold text
|
||||
Pry.color ? "\e[1m#{text}\e[0m" : text.to_s
|
||||
end
|
||||
|
||||
# Executes _block_ with _Pry.color_ set to false.
|
||||
#
|
||||
# @param [Proc]
|
||||
def no_color &block
|
||||
boolean = Pry.color
|
||||
Pry.color = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue