Class: String
Instance Method Summary collapse
- #force_encoding(encoding) ⇒ 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 |
#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 |