Module: ANSI::Mixin

Defined in:
lib/ansi/mixin.rb

Overview

This module is designed specifically for mixing into String-like classes or extending String-like objects.

Generally speaking the String#ansi method is the more elegant approach to modifying a string with codes via a method call. But in some cases this Mixin’s design might be preferable. Indeed, it original intent was as a compatability layer for the colored gem.

Instance Method Summary collapse

Instance Method Details

#blackObject



27
# File 'lib/ansi/mixin.rb', line 27

def black      ; ANSI::Code.black      { to_s } ; end

#black_on_blueObject



48
# File 'lib/ansi/mixin.rb', line 48

def black_on_blue     ; ANSI::Code.black_on_blue     { to_s } ; end

#black_on_cyanObject



50
# File 'lib/ansi/mixin.rb', line 50

def black_on_cyan     ; ANSI::Code.black_on_cyan     { to_s } ; end

#black_on_greenObject



46
# File 'lib/ansi/mixin.rb', line 46

def black_on_green    ; ANSI::Code.black_on_green    { to_s } ; end

#black_on_magentaObject



49
# File 'lib/ansi/mixin.rb', line 49

def black_on_magenta  ; ANSI::Code.black_on_magenta  { to_s } ; end

#black_on_redObject



45
# File 'lib/ansi/mixin.rb', line 45

def black_on_red      ; ANSI::Code.black_on_red      { to_s } ; end

#black_on_whiteObject



51
# File 'lib/ansi/mixin.rb', line 51

def black_on_white    ; ANSI::Code.black_on_white    { to_s } ; end

#black_on_yellowObject



47
# File 'lib/ansi/mixin.rb', line 47

def black_on_yellow   ; ANSI::Code.black_on_yellow   { to_s } ; end


20
# File 'lib/ansi/mixin.rb', line 20

def blink      ; ANSI::Code.blink      { to_s } ; end

#blueObject



31
# File 'lib/ansi/mixin.rb', line 31

def blue       ; ANSI::Code.blue       { to_s } ; end

#blue_on_blackObject



77
# File 'lib/ansi/mixin.rb', line 77

def blue_on_black     ; ANSI::Code.blue_on_black     { to_s } ; end

#blue_on_cyanObject



82
# File 'lib/ansi/mixin.rb', line 82

def blue_on_cyan      ; ANSI::Code.blue_on_cyan      { to_s } ; end

#blue_on_greenObject



79
# File 'lib/ansi/mixin.rb', line 79

def blue_on_green     ; ANSI::Code.blue_on_green     { to_s } ; end

#blue_on_magentaObject



81
# File 'lib/ansi/mixin.rb', line 81

def blue_on_magenta   ; ANSI::Code.blue_on_magenta   { to_s } ; end

#blue_on_redObject



78
# File 'lib/ansi/mixin.rb', line 78

def blue_on_red       ; ANSI::Code.blue_on_red       { to_s } ; end

#blue_on_whiteObject



83
# File 'lib/ansi/mixin.rb', line 83

def blue_on_white     ; ANSI::Code.blue_on_white     { to_s } ; end

#blue_on_yellowObject



80
# File 'lib/ansi/mixin.rb', line 80

def blue_on_yellow    ; ANSI::Code.blue_on_yellow    { to_s } ; end

#boldObject



15
# File 'lib/ansi/mixin.rb', line 15

def bold       ; ANSI::Code.bold       { to_s } ; end

#concealedObject



24
# File 'lib/ansi/mixin.rb', line 24

def concealed  ; ANSI::Code.concealed  { to_s } ; end

#cyanObject



33
# File 'lib/ansi/mixin.rb', line 33

def cyan       ; ANSI::Code.cyan       { to_s } ; end

#cyan_on_blackObject



93
# File 'lib/ansi/mixin.rb', line 93

def cyan_on_black     ; ANSI::Code.cyan_on_black     { to_s } ; end

#cyan_on_blueObject



97
# File 'lib/ansi/mixin.rb', line 97

def cyan_on_blue      ; ANSI::Code.cyan_on_blue      { to_s } ; end

#cyan_on_greenObject



95
# File 'lib/ansi/mixin.rb', line 95

def cyan_on_green     ; ANSI::Code.cyan_on_green     { to_s } ; end

#cyan_on_magentaObject



98
# File 'lib/ansi/mixin.rb', line 98

def cyan_on_magenta   ; ANSI::Code.cyan_on_magenta   { to_s } ; end

#cyan_on_redObject



94
# File 'lib/ansi/mixin.rb', line 94

def cyan_on_red       ; ANSI::Code.cyan_on_red       { to_s } ; end

#cyan_on_whiteObject



99
# File 'lib/ansi/mixin.rb', line 99

def cyan_on_white     ; ANSI::Code.cyan_on_white     { to_s } ; end

#cyan_on_yellowObject



96
# File 'lib/ansi/mixin.rb', line 96

def cyan_on_yellow    ; ANSI::Code.cyan_on_yellow    { to_s } ; end

#darkObject



16
# File 'lib/ansi/mixin.rb', line 16

def dark       ; ANSI::Code.dark       { to_s } ; end

#display(line, column = 0) ⇒ Object

Move cursor to line and column, insert self.to_s and return to original positon.



111
112
113
114
115
116
117
# File 'lib/ansi/mixin.rb', line 111

def display(line, column=0)
  result = "\e[s"
  result << "\e[#{line.to_i};#{column.to_i}H"
  result << to_s
  result << "\e[u"
  result
end

#greenObject



29
# File 'lib/ansi/mixin.rb', line 29

def green      ; ANSI::Code.green      { to_s } ; end

#green_on_blackObject



61
# File 'lib/ansi/mixin.rb', line 61

def green_on_black    ; ANSI::Code.green_on_black    { to_s } ; end

#green_on_blueObject



64
# File 'lib/ansi/mixin.rb', line 64

def green_on_blue     ; ANSI::Code.green_on_blue     { to_s } ; end

#green_on_cyanObject



66
# File 'lib/ansi/mixin.rb', line 66

def green_on_cyan     ; ANSI::Code.green_on_cyan     { to_s } ; end

#green_on_magentaObject



65
# File 'lib/ansi/mixin.rb', line 65

def green_on_magenta  ; ANSI::Code.green_on_magenta  { to_s } ; end

#green_on_redObject



62
# File 'lib/ansi/mixin.rb', line 62

def green_on_red      ; ANSI::Code.green_on_red      { to_s } ; end

#green_on_whiteObject



67
# File 'lib/ansi/mixin.rb', line 67

def green_on_white    ; ANSI::Code.green_on_white    { to_s } ; end

#green_on_yellowObject



63
# File 'lib/ansi/mixin.rb', line 63

def green_on_yellow   ; ANSI::Code.green_on_yellow   { to_s } ; end

#italicObject



17
# File 'lib/ansi/mixin.rb', line 17

def italic     ; ANSI::Code.italic     { to_s } ; end

#magentaObject



32
# File 'lib/ansi/mixin.rb', line 32

def magenta    ; ANSI::Code.magenta    { to_s } ; end

#magenta_on_blackObject



85
# File 'lib/ansi/mixin.rb', line 85

def magenta_on_black  ; ANSI::Code.magenta_on_black  { to_s } ; end

#magenta_on_blueObject



89
# File 'lib/ansi/mixin.rb', line 89

def magenta_on_blue   ; ANSI::Code.magenta_on_blue   { to_s } ; end

#magenta_on_cyanObject



90
# File 'lib/ansi/mixin.rb', line 90

def magenta_on_cyan   ; ANSI::Code.magenta_on_cyan   { to_s } ; end

#magenta_on_greenObject



87
# File 'lib/ansi/mixin.rb', line 87

def magenta_on_green  ; ANSI::Code.magenta_on_green  { to_s } ; end

#magenta_on_redObject



86
# File 'lib/ansi/mixin.rb', line 86

def magenta_on_red    ; ANSI::Code.magenta_on_red    { to_s } ; end

#magenta_on_whiteObject



91
# File 'lib/ansi/mixin.rb', line 91

def magenta_on_white  ; ANSI::Code.magenta_on_white  { to_s } ; end

#magenta_on_yellowObject



88
# File 'lib/ansi/mixin.rb', line 88

def magenta_on_yellow ; ANSI::Code.magenta_on_yellow { to_s } ; end

#negativeObject



23
# File 'lib/ansi/mixin.rb', line 23

def negative   ; ANSI::Code.negative   { to_s } ; end

#on_blackObject



36
# File 'lib/ansi/mixin.rb', line 36

def on_black   ; ANSI::Code.on_black   { to_s } ; end

#on_blueObject



40
# File 'lib/ansi/mixin.rb', line 40

def on_blue    ; ANSI::Code.on_blue    { to_s } ; end

#on_cyanObject



42
# File 'lib/ansi/mixin.rb', line 42

def on_cyan    ; ANSI::Code.on_cyan    { to_s } ; end

#on_greenObject



38
# File 'lib/ansi/mixin.rb', line 38

def on_green   ; ANSI::Code.on_green   { to_s } ; end

#on_magentaObject



41
# File 'lib/ansi/mixin.rb', line 41

def on_magenta ; ANSI::Code.on_magenta { to_s } ; end

#on_redObject



37
# File 'lib/ansi/mixin.rb', line 37

def on_red     ; ANSI::Code.on_red     { to_s } ; end

#on_whiteObject



43
# File 'lib/ansi/mixin.rb', line 43

def on_white   ; ANSI::Code.on_white   { to_s } ; end

#on_yellowObject



39
# File 'lib/ansi/mixin.rb', line 39

def on_yellow  ; ANSI::Code.on_yellow  { to_s } ; end

#rapidObject



21
# File 'lib/ansi/mixin.rb', line 21

def rapid      ; ANSI::Code.rapid      { to_s } ; end

#redObject



28
# File 'lib/ansi/mixin.rb', line 28

def red        ; ANSI::Code.red        { to_s } ; end

#red_on_blackObject



53
# File 'lib/ansi/mixin.rb', line 53

def red_on_black      ; ANSI::Code.red_on_black      { to_s } ; end

#red_on_blueObject



56
# File 'lib/ansi/mixin.rb', line 56

def red_on_blue       ; ANSI::Code.red_on_blue       { to_s } ; end

#red_on_cyanObject



58
# File 'lib/ansi/mixin.rb', line 58

def red_on_cyan       ; ANSI::Code.red_on_cyan       { to_s } ; end

#red_on_greenObject



54
# File 'lib/ansi/mixin.rb', line 54

def red_on_green      ; ANSI::Code.red_on_green      { to_s } ; end

#red_on_magentaObject



57
# File 'lib/ansi/mixin.rb', line 57

def red_on_magenta    ; ANSI::Code.red_on_magenta    { to_s } ; end

#red_on_whiteObject



59
# File 'lib/ansi/mixin.rb', line 59

def red_on_white      ; ANSI::Code.red_on_white      { to_s } ; end

#red_on_yellowObject



55
# File 'lib/ansi/mixin.rb', line 55

def red_on_yellow     ; ANSI::Code.red_on_yellow     { to_s } ; end

#reverseObject



22
# File 'lib/ansi/mixin.rb', line 22

def reverse    ; ANSI::Code.reverse    { to_s } ; end

#strikeObject



25
# File 'lib/ansi/mixin.rb', line 25

def strike     ; ANSI::Code.strike     { to_s } ; end

#underlineObject



18
# File 'lib/ansi/mixin.rb', line 18

def underline  ; ANSI::Code.underline  { to_s } ; end

#underscoreObject



19
# File 'lib/ansi/mixin.rb', line 19

def underscore ; ANSI::Code.underscore { to_s } ; end

#whiteObject



34
# File 'lib/ansi/mixin.rb', line 34

def white      ; ANSI::Code.white      { to_s } ; end

#white_on_blackObject



101
# File 'lib/ansi/mixin.rb', line 101

def white_on_black    ; ANSI::Code.white_on_black    { to_s } ; end

#white_on_blueObject



105
# File 'lib/ansi/mixin.rb', line 105

def white_on_blue     ; ANSI::Code.white_on_blue     { to_s } ; end

#white_on_cyanObject



107
# File 'lib/ansi/mixin.rb', line 107

def white_on_cyan     ; ANSI::Code.white_on_cyan     { to_s } ; end

#white_on_greenObject



103
# File 'lib/ansi/mixin.rb', line 103

def white_on_green    ; ANSI::Code.white_on_green    { to_s } ; end

#white_on_magentaObject



106
# File 'lib/ansi/mixin.rb', line 106

def white_on_magenta  ; ANSI::Code.white_on_magenta  { to_s } ; end

#white_on_redObject



102
# File 'lib/ansi/mixin.rb', line 102

def white_on_red      ; ANSI::Code.white_on_red      { to_s } ; end

#white_on_yellowObject



104
# File 'lib/ansi/mixin.rb', line 104

def white_on_yellow   ; ANSI::Code.white_on_yellow   { to_s } ; end

#yellowObject



30
# File 'lib/ansi/mixin.rb', line 30

def yellow     ; ANSI::Code.yellow     { to_s } ; end

#yellow_on_blackObject



69
# File 'lib/ansi/mixin.rb', line 69

def yellow_on_black   ; ANSI::Code.yellow_on_black   { to_s } ; end

#yellow_on_blueObject



72
# File 'lib/ansi/mixin.rb', line 72

def yellow_on_blue    ; ANSI::Code.yellow_on_blue    { to_s } ; end

#yellow_on_cyanObject



74
# File 'lib/ansi/mixin.rb', line 74

def yellow_on_cyan    ; ANSI::Code.yellow_on_cyan    { to_s } ; end

#yellow_on_greenObject



71
# File 'lib/ansi/mixin.rb', line 71

def yellow_on_green   ; ANSI::Code.yellow_on_green   { to_s } ; end

#yellow_on_magentaObject



73
# File 'lib/ansi/mixin.rb', line 73

def yellow_on_magenta ; ANSI::Code.yellow_on_magenta { to_s } ; end

#yellow_on_redObject



70
# File 'lib/ansi/mixin.rb', line 70

def yellow_on_red     ; ANSI::Code.yellow_on_red     { to_s } ; end

#yellow_on_whiteObject



75
# File 'lib/ansi/mixin.rb', line 75

def yellow_on_white   ; ANSI::Code.yellow_on_white   { to_s } ; end