Module: Ergane::Util
- Defined in:
- lib/ergane/util.rb
Class Method Summary collapse
- .color_array(array) ⇒ Object
- .color_array!(array) ⇒ Object
- .colors ⇒ Object
- .first_name ⇒ Object
- .full_name ⇒ Object
- .last_name ⇒ Object
- .next_color ⇒ Object
- .next_rainbow_color ⇒ Object
- .rainbow(string, delimeter = ' ') ⇒ Object
- .rainbow!(string, delimeter = ' ') ⇒ Object
- .rainbow_a(array) ⇒ Object
- .rainbow_a!(array) ⇒ Object
- .rainbow_colors ⇒ Object
Class Method Details
.color_array(array) ⇒ Object
9 10 11 12 13 |
# File 'lib/ergane/util.rb', line 9 def self.color_array(array) array.collect do |a| a.to_s.send(colors.next.to_sym).underline end end |
.color_array!(array) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ergane/util.rb', line 15 def self.color_array!(array) colors.rewind array.collect do |a| a.to_s.send(colors.next.to_sym).underline end end |
.colors ⇒ Object
4 5 6 7 |
# File 'lib/ergane/util.rb', line 4 def self.colors # @colors = [:red, :yellow, :green, :blue, :cyan, :magenta].cycle @colors ||= [:light_red, :light_yellow, :light_green, :light_blue, :light_cyan, :light_magenta].cycle end |
.first_name ⇒ Object
65 66 67 68 69 |
# File 'lib/ergane/util.rb', line 65 def self.first_name @first_name || begin split_names.first end end |
.full_name ⇒ Object
55 56 57 |
# File 'lib/ergane/util.rb', line 55 def self.full_name @full_name ||= `finger \`whoami\` | grep Name | awk -F 'Name: ' '{print $2}'`.chomp end |
.last_name ⇒ Object
59 60 61 62 63 |
# File 'lib/ergane/util.rb', line 59 def self.last_name @last_name || begin split_names.last end end |
.next_color ⇒ Object
43 44 45 |
# File 'lib/ergane/util.rb', line 43 def self.next_color colors.next end |
.next_rainbow_color ⇒ Object
51 52 53 |
# File 'lib/ergane/util.rb', line 51 def self.next_rainbow_color rainbow_colors.cycle end |
.rainbow(string, delimeter = ' ') ⇒ Object
22 23 24 |
# File 'lib/ergane/util.rb', line 22 def self.rainbow(string, delimeter=' ') rainbow_a(string.split(delimeter)).join(delimeter) end |
.rainbow!(string, delimeter = ' ') ⇒ Object
26 27 28 |
# File 'lib/ergane/util.rb', line 26 def self.rainbow!(string, delimeter=' ') rainbow_a!(string.split(delimeter)).join(delimeter) end |
.rainbow_a(array) ⇒ Object
30 31 32 33 34 |
# File 'lib/ergane/util.rb', line 30 def self.rainbow_a(array) array.collect do |a| a.to_s.send(next_color).underline end end |
.rainbow_a!(array) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ergane/util.rb', line 36 def self.rainbow_a!(array) rainbow_colors.rewind array.collect do |a| a.to_s.send(next_color).underline end end |
.rainbow_colors ⇒ Object
47 48 49 |
# File 'lib/ergane/util.rb', line 47 def self.rainbow_colors @rainbow_colors = [:light_red, :light_yellow, :light_green, :light_blue, :light_cyan, :light_magenta].cycle end |