tiny_color 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tiny_color.rb +55 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ab6f7f97772572db9f9150f29e255d3115b8c63f07235779950d608981978065
4
+ data.tar.gz: 0bc3fa123e8062f1a08561ec028fb3372c82794a22171b1d1a2bbbc3b81d6250
5
+ SHA512:
6
+ metadata.gz: e41b28487f9a48a768375d16200e8d5a8ed65f5565b9073ff526cf2e3ca9338969b2b9cc6043a386f77ca58239432e4f5f4efdeb78089a1c8f22e7aa562347e5
7
+ data.tar.gz: a28dfad2340703e9eda86b7639a8e77f05ec819b8ae3776f03acef20042cbd18d3bd3132bdb3510748b994ba18ddbcd49c2b488c7e3545a096fadec0705ba412
data/lib/tiny_color.rb ADDED
@@ -0,0 +1,55 @@
1
+ # this code extends the String class, adding ANSI color codes for modifying the
2
+ # text.
3
+ #
4
+ # usage:
5
+ # puts 'Hi'.green + ' there!'
6
+ #
7
+ # "Hi there!" # where 'Hi' will appear in green,
8
+ # # and the rest in your # default
9
+ # # terminal color
10
+ #
11
+ # you can also add background colors:
12
+ # puts 'Hi'.black.on_yellow + ' there!'
13
+ #
14
+ # "Hi there!" # where 'Hi' will appear in black
15
+ # # with a yellow background, and the
16
+ # # rest in your default terminal
17
+ # # color
18
+ class String
19
+ COLORS = {
20
+ black: 30,
21
+ light_black: 90,
22
+
23
+ red: 31,
24
+ light_red: 91,
25
+
26
+ green: 32,
27
+ light_green: 92,
28
+
29
+ yellow: 33,
30
+ light_yellow: 93,
31
+
32
+ blue: 34,
33
+ light_blue: 94,
34
+
35
+ purple: 35,
36
+ light_purple: 95,
37
+
38
+ cyan: 36,
39
+ light_cyan: 96,
40
+
41
+ white: 37,
42
+ light_white: 97
43
+ }
44
+
45
+ COLORS.each do |color, value|
46
+ define_method color do
47
+ "\033[#{value}m#{self}\033[0m"
48
+ end
49
+
50
+ define_method "on_#{color}" do
51
+ "\033[#{value + 10}m#{self}\033[0m"
52
+ end
53
+ end
54
+ end
55
+
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_color
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Lunt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: a tiny library for String colorization
14
+ email: jefflunt@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/tiny_color.rb
20
+ homepage: https://github.com/jefflunt/tiny_color
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.4.1
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: this is a minimalist library for colorinzing Strings, via extending the String
43
+ class
44
+ test_files: []