Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/twat.rb

Instance Method Summary collapse

Instance Method Details

#blackObject

TODO - It’d be nice to implement the colors support here, maybe even only mix this in if it’s enabled?



18
19
20
# File 'lib/twat.rb', line 18

def black
  "#{self}"
end

#blueObject



34
35
36
# File 'lib/twat.rb', line 34

def blue
  "#{self}"
end

#boldObject



42
43
44
# File 'lib/twat.rb', line 42

def bold
  "#{self}"
end

#colorise!Object



50
51
52
53
54
# File 'lib/twat.rb', line 50

def colorise!
  colorise_handles!
  colorise_hashtags!
  colorise_urls!
end

#colorise_handles!Object



56
57
58
59
# File 'lib/twat.rb', line 56

def colorise_handles!
  self.gsub!(/@[a-z0-9_+-]+/i) { |s| s.cyan }
  return self
end

#colorise_hashtags!Object



61
62
63
64
# File 'lib/twat.rb', line 61

def colorise_hashtags!
  self.gsub!(/#[a-z0-9_+-]+/i) { |s| s.cyan }
  return self
end

#colorise_urls!Object



66
67
68
69
# File 'lib/twat.rb', line 66

def colorise_urls!
  self.gsub!(%r{https?://[a-z0-9./_+-]+}i) { |s| s.black }
  return self
end

#cyanObject



38
39
40
# File 'lib/twat.rb', line 38

def cyan
  "#{self}"
end

#greenObject



26
27
28
# File 'lib/twat.rb', line 26

def green
  "#{self}"
end

#mentions?(name) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/twat.rb', line 46

def mentions?(name)
  return self.downcase.include?(name.to_s.downcase)
end

#redObject



22
23
24
# File 'lib/twat.rb', line 22

def red
  "#{self}"
end

#yellowObject



30
31
32
# File 'lib/twat.rb', line 30

def yellow
  "#{self}"
end