Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/unroller.rb,
lib/unroller.rb
Instance Method Summary collapse
-
#menu_item(color = :white, letter = , which_occurence = 0) ⇒ Object
Makes the first character bold and underlined.
Instance Method Details
#menu_item(color = :white, letter = , which_occurence = 0) ⇒ Object
Makes the first character bold and underlined. Makes the whole string of the given color. :todo: Move out to extensions/console/menu_item
99 100 101 102 103 104 105 106 |
# File 'lib/unroller.rb', line 99 def (color = :white, letter = self[0..0], which_occurence = 0) index = index_all(/#{letter}/)[which_occurence] raise "Could not find a #{which_occurence}th occurence of '#{letter}' in string '#{self}'" if index.nil? before = self[0..index-1].send(color) unless index == 0 middle = self[index..index].send(color).bold.underline after = self[index+1..-1].send(color) before.to_s + middle + after end |