Class: String
- Defined in:
- lib/ruco/core_ext/string.rb,
lib/ruco/core_ext/string.rb
Overview
Instance Method Summary collapse
- #force_encoding(encoding) ⇒ Object
- #indexes(needle) ⇒ Object
- #leading_whitespace ⇒ Object
- #naive_split(pattern) ⇒ Object
- #ord ⇒ Object
- #tabs_to_spaces! ⇒ Object
Instance Method Details
#force_encoding(encoding) ⇒ Object
25 26 27 |
# File 'lib/ruco/core_ext/string.rb', line 25 def force_encoding(encoding) self end |
#indexes(needle) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ruco/core_ext/string.rb', line 39 def indexes(needle) found = [] current_index = -1 while current_index = index(needle, current_index+1) found << current_index end found end |
#leading_whitespace ⇒ Object
19 20 21 |
# File 'lib/ruco/core_ext/string.rb', line 19 def leading_whitespace match(/^\s*/)[0] end |
#naive_split(pattern) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/ruco/core_ext/string.rb', line 2 def naive_split(pattern) string = self.dup found = [] while position = string.index(pattern) found << string.slice!(0, position) string.slice!(0,[pattern.size,1].max) end found << string found end |
#ord ⇒ Object
31 32 33 |
# File 'lib/ruco/core_ext/string.rb', line 31 def ord bytes.first end |