class Colours::Demo
Public Class Methods
all_ansi_256()
click to toggle source
# File lib/colours.rb, line 171 def all_ansi_256 puts display_all_ansi_256('bg') puts puts display_all_ansi_256('fg') puts puts display_all(styles) puts puts display_all(fg_colours) puts puts display_all(bright_colours) puts puts display_all(bg_colours) puts puts end
Private Class Methods
bg_colours()
click to toggle source
# File lib/colours.rb, line 245 def bg_colours { bg_black: :white, bg_blue: :black, bg_cyan: :black, bg_green: :black, bg_magenta: :black, bg_red: :black, bg_white: :black, bg_yellow: :black } end
bright_colours()
click to toggle source
# File lib/colours.rb, line 232 def bright_colours { bright_black: :bg_black, bright_blue: :bg_black, bright_cyan: :bg_black, bright_green: :bg_black, bright_magenta: :bg_black, bright_red: :bg_black, bright_white: :bg_black, bright_yellow: :bg_black } end
col_width()
click to toggle source
# File lib/colours.rb, line 275 def col_width @col_width ||= '.bright_magenta '.length end
display_all(formats)
click to toggle source
# File lib/colours.rb, line 195 def display_all(formats) codes_displayed = 1 formats.each do |method, complementary_method| print ".#{method}".ljust(col_width).send(method).send(complementary_method) codes_displayed += 1 if codes_displayed * col_width > screen_width puts codes_displayed = 1 end end end
display_all_ansi_256(method)
click to toggle source
# File lib/colours.rb, line 258 def display_all_ansi_256(method) # Use `Colours::Demo.all_ansi_256` to see colours available codes_displayed = 1 256.times do |code| print ".#{method}(#{code})".ljust(col_width).send(method, code).fg(89) codes_displayed += 1 if codes_displayed * col_width + 2 > screen_width puts codes_displayed = 1 end end end
fg_colours()
click to toggle source
# File lib/colours.rb, line 219 def fg_colours { black: :near_black, blue: :bg_black, cyan: :bg_black, green: :bg_black, magenta: :bg_black, red: :bg_black, white: :bg_black, yellow: :bg_black } end
screen_width()
click to toggle source
# File lib/colours.rb, line 279 def screen_width @screen_width ||= `tput cols`.to_i end
styles()
click to toggle source
# File lib/colours.rb, line 210 def styles { bold: :white, faint: :white, italic: :white, underline: :white } end