Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/twat.rb
Instance Method Summary collapse
-
#black ⇒ Object
TODO - It’d be nice to implement the colors support here, maybe even only mix this in if it’s enabled?.
- #blue ⇒ Object
- #bold ⇒ Object
- #colorise! ⇒ Object
- #colorise_handles! ⇒ Object
- #colorise_hashtags! ⇒ Object
- #colorise_urls! ⇒ Object
- #cyan ⇒ Object
- #green ⇒ Object
- #mentions?(name) ⇒ Boolean
- #red ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#black ⇒ Object
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 "[30m#{self}[39m" end |
#blue ⇒ Object
34 35 36 |
# File 'lib/twat.rb', line 34 def blue "[34m#{self}[39m" end |
#bold ⇒ Object
42 43 44 |
# File 'lib/twat.rb', line 42 def bold "[1m#{self}[22m" end |
#colorise! ⇒ Object
50 51 52 53 54 |
# File 'lib/twat.rb', line 50 def colorise! colorise_handles! 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 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 |
#cyan ⇒ Object
38 39 40 |
# File 'lib/twat.rb', line 38 def cyan "[36m#{self}[39m" end |
#green ⇒ Object
26 27 28 |
# File 'lib/twat.rb', line 26 def green "[32m#{self}[39m" end |
#mentions?(name) ⇒ Boolean
46 47 48 |
# File 'lib/twat.rb', line 46 def mentions?(name) return self.downcase.include?(name.to_s.downcase) end |
#red ⇒ Object
22 23 24 |
# File 'lib/twat.rb', line 22 def red "[31m#{self}[39m" end |
#yellow ⇒ Object
30 31 32 |
# File 'lib/twat.rb', line 30 def yellow "[33m#{self}[39m" end |