Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/term/code.rb,
lib/term/font.rb,
lib/term/color.rb,
lib/term/style.rb,
lib/term/qrcode.rb,
lib/term/confirm.rb
Overview
Constant Summary collapse
- COLOR =
string colors.
{ black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, light_gray: 37, default_color: 39, dark_gray: 90, light_red: 91, light_green: 92, light_yellow: 93, light_blue: 94, light_magenta: 95, light_cyan: 96, white: 97 }.freeze
- STYLE =
string styles. see ANSI/VT100 Control sequences.
{ bold: 1, dim: 2, italicized: 3, underlined: 4, blink: 5, inverse: 7, hidden: 8, crossed_out: 9 }.freeze
Class Attribute Summary collapse
-
.fonts ⇒ Object
Returns the value of attribute fonts.
Instance Method Summary collapse
-
#background_color(name) ⇒ String
string background color.
-
#black ⇒ String
black string.
-
#black_background ⇒ String
black background string.
-
#blink ⇒ String
blink string.
-
#blue ⇒ String
blue string.
-
#blue_background ⇒ String
blue background string.
-
#bold ⇒ String
blod string.
-
#code(name) ⇒ String
a code syntax highlighter.
-
#color(name) ⇒ String
string color.
-
#crossed_out ⇒ String
crossed out string.
-
#cyan ⇒ String
cyan string.
-
#cyan_background ⇒ String
cyan background string.
-
#dark_gray ⇒ String
dark gray string.
-
#dark_gray_background ⇒ String
dark gray background string.
-
#default_color ⇒ String
default color string.
-
#default_color_background ⇒ String
default color background string.
-
#dim ⇒ String
dim string.
-
#font(name) ⇒ String
set the font.
-
#green ⇒ String
green string.
-
#green_background ⇒ String
green background string.
-
#hidden ⇒ String
hidden string.
-
#inverse ⇒ String
nvert the foreground and background colors.
-
#italicized ⇒ String
italicized string.
-
#light_blue ⇒ String
light blue string.
-
#light_blue_background ⇒ String
light blue background string.
-
#light_cyan ⇒ String
light cyan string.
-
#light_cyan_background ⇒ String
light cyan background string.
-
#light_gray ⇒ String
light gray string.
-
#light_gray_background ⇒ String
light gray background string.
-
#light_green ⇒ String
light green string.
-
#light_green_background ⇒ String
light green background string.
-
#light_magenta ⇒ String
light magenta string.
-
#light_magenta_background ⇒ String
light magenta background string.
-
#light_red ⇒ String
light red string.
-
#light_red_background ⇒ String
light red background string.
-
#light_yellow ⇒ String
light yellow string.
-
#light_yellow_background ⇒ String
light yellow background string.
-
#magenta ⇒ String
magenta string.
-
#magenta_background ⇒ String
magenta background string.
- #ok? ⇒ Boolean
-
#qrcode ⇒ String
get qrcode.
-
#red ⇒ String
red string.
-
#red_background ⇒ String
red background string.
-
#reset ⇒ String
reset all attributes.
-
#reset_blink ⇒ String
reset blink string.
-
#reset_bold ⇒ String
reset bold string.
-
#reset_crossed_out ⇒ String
reset crossed out string.
-
#reset_dim ⇒ String
reset dim string.
-
#reset_hidden ⇒ String
reset hidden string.
-
#reset_inverse ⇒ String
reset inverse string.
-
#reset_italicized ⇒ String
reset italicized string.
-
#reset_underlined ⇒ String
reset underlined string.
-
#underlined ⇒ String
underlined string.
-
#white ⇒ String
white string.
-
#white_background ⇒ String
white background string.
-
#yellow ⇒ String
yellow string.
-
#yellow_background ⇒ String
yellow background string.
Class Attribute Details
.fonts ⇒ Object
Returns the value of attribute fonts.
8 9 10 |
# File 'lib/term/font.rb', line 8 def fonts @fonts end |
Instance Method Details
#background_color(name) ⇒ String
string background color.
226 227 228 229 |
# File 'lib/term/color.rb', line 226 def background_color(name) set_256_color(name, 48) || set_rbg_color(name, 48) || set_keyword_color(name, '_background') || self end |
#blink ⇒ String
works in the tty and XIO.
blink string.
does not work with most of the terminal emulators
|
# File 'lib/term/style.rb', line 72
|
#code(name) ⇒ String
a code syntax highlighter.
21 22 23 |
# File 'lib/term/code.rb', line 21 def code(name) Rouge.highlight(self, name.to_s, 'terminal256') end |
#color(name) ⇒ String
string color.
213 214 215 216 |
# File 'lib/term/color.rb', line 213 def color(name) set_256_color(name) || set_rbg_color(name) || set_keyword_color(name) || self end |
#default_color_background ⇒ String
default color background string.
|
# File 'lib/term/color.rb', line 112
|
#font(name) ⇒ String
using ‘artii` gem. typing `artii -l` to see all fonts.
set the font.
19 20 21 22 |
# File 'lib/term/font.rb', line 19 def font(name) font_builder = self.class.fonts[name.to_s] ||= Artii::Base.new(font: name) font_builder.output self end |
#light_green_background ⇒ String
light green background string.
|
# File 'lib/term/color.rb', line 142
|
#light_magenta_background ⇒ String
light magenta background string.
|
# File 'lib/term/color.rb', line 172
|
#light_yellow_background ⇒ String
light yellow background string.
|
# File 'lib/term/color.rb', line 152
|
#ok? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/term/confirm.rb', line 10 def ok? print "#{self}? ".green @begin_confirm_pos = IO.hide.pos process_confirm_input IO.show @res end |
#qrcode ⇒ String
get qrcode.
12 13 14 |
# File 'lib/term/qrcode.rb', line 12 def qrcode RQRCode::QRCode.new(self).as_ansi(quiet_zone_size: 0) end |
#reset ⇒ String
reset all attributes.
11 12 13 |
# File 'lib/term/style.rb', line 11 def reset "\e[0m#{self}\e[0m" end |
#reset_crossed_out ⇒ String
reset crossed out string.
118 119 120 121 122 123 124 125 |
# File 'lib/term/style.rb', line 118 STYLE.each do |name, value| define_method(name) do "\e[#{value}m#{self}\e[0m" end define_method("reset_#{name}") do "\e[#{10 + value}m#{self}\e[0m" end end |