Class: String

Inherits:
Object show all
Defined in:
lib/chitin/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#-@Object



4
5
6
# File 'lib/chitin/core_ext/string.rb', line 4

def -@
  "-#{self}"
end

#/(other) ⇒ Object

Make an executable out of File.join(self, other)



31
32
33
# File 'lib/chitin/core_ext/string.rb', line 31

def /(other)
  Chitin::Executable.new File.join(self, other.to_s)
end

#>(other) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/chitin/core_ext/string.rb', line 52

def >(other)
  case other
  when Chitin::FileObject
    other.to_a.each do |fo|
      next if fo.directory?

      File.open(fo.to_s, 'w') {|f| f.puts self }
    end
  when String
    File.open(other, 'w') {|f| f.puts self }
  else
    raise "Unknown piping type: #{other.class}"
  end

  other
end

#>>(other) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chitin/core_ext/string.rb', line 35

def >>(other)
  case other
  when Chitin::FileObject
    other.to_a.each do |fo|
      next if fo.directory?

      File.open(fo.to_s, 'a') {|f| f.puts self }
    end
  when String
    File.open(other, 'a') {|f| f.puts self }
  else
    raise "Unknown piping type: #{other.class}"
  end

  other
end

#blackObject



9
# File 'lib/chitin/core_ext/string.rb', line 9

def black       ; Wirble::Colorize.colorize_string self, :black       ; end

#blueObject



13
# File 'lib/chitin/core_ext/string.rb', line 13

def blue        ; Wirble::Colorize.colorize_string self, :blue        ; end

#brownObject



12
# File 'lib/chitin/core_ext/string.rb', line 12

def brown       ; Wirble::Colorize.colorize_string self, :brown       ; end

#cyanObject



14
# File 'lib/chitin/core_ext/string.rb', line 14

def cyan        ; Wirble::Colorize.colorize_string self, :cyan        ; end

#dark_grayObject



17
# File 'lib/chitin/core_ext/string.rb', line 17

def dark_gray   ; Wirble::Colorize.colorize_string self, :dark_gray   ; end

#greenObject



11
# File 'lib/chitin/core_ext/string.rb', line 11

def green       ; Wirble::Colorize.colorize_string self, :green       ; end

#light_blueObject



21
# File 'lib/chitin/core_ext/string.rb', line 21

def light_blue  ; Wirble::Colorize.colorize_string self, :light_blue  ; end

#light_cyanObject



22
# File 'lib/chitin/core_ext/string.rb', line 22

def light_cyan  ; Wirble::Colorize.colorize_string self, :light_cyan  ; end

#light_grayObject



16
# File 'lib/chitin/core_ext/string.rb', line 16

def light_gray  ; Wirble::Colorize.colorize_string self, :light_gray  ; end

#light_greenObject



19
# File 'lib/chitin/core_ext/string.rb', line 19

def light_green ; Wirble::Colorize.colorize_string self, :light_green ; end

#light_purpleObject



23
# File 'lib/chitin/core_ext/string.rb', line 23

def light_purple; Wirble::Colorize.colorize_string self, :light_purple; end

#light_redObject



18
# File 'lib/chitin/core_ext/string.rb', line 18

def light_red   ; Wirble::Colorize.colorize_string self, :light_red   ; end

#map_lines(&block) ⇒ Object



26
27
28
# File 'lib/chitin/core_ext/string.rb', line 26

def map_lines(&block)
  split("\n").map(&block)
end

#nothingObject



8
# File 'lib/chitin/core_ext/string.rb', line 8

def nothing     ; Wirble::Colorize.colorize_string self, :nothing     ; end

#purpleObject



15
# File 'lib/chitin/core_ext/string.rb', line 15

def purple      ; Wirble::Colorize.colorize_string self, :purple      ; end

#redObject



10
# File 'lib/chitin/core_ext/string.rb', line 10

def red         ; Wirble::Colorize.colorize_string self, :red         ; end

#whiteObject



24
# File 'lib/chitin/core_ext/string.rb', line 24

def white       ; Wirble::Colorize.colorize_string self, :white       ; end

#yellowObject



20
# File 'lib/chitin/core_ext/string.rb', line 20

def yellow      ; Wirble::Colorize.colorize_string self, :yellow      ; end

#|(other) ⇒ Object



69
70
71
# File 'lib/chitin/core_ext/string.rb', line 69

def |(other)
  NULLIN > L { self } | other
end