Module: StringUtil
- Included in:
- MarkdownExec::MarkParse
- Defined in:
- lib/string_util.rb
Class Method Summary collapse
-
.partition_at_first(input_str, split_char) ⇒ Array<String>
Splits the given string on the first occurrence of the specified character.
Class Method Details
.partition_at_first(input_str, split_char) ⇒ Array<String>
Splits the given string on the first occurrence of the specified character. Returns an array containing the portion of the string before the character and the rest of the string.
12 13 14 15 16 17 18 19 20 |
# File 'lib/string_util.rb', line 12 def self.partition_at_first(input_str, split_char) split_index = input_str.index(split_char) if split_index.nil? [input_str, ''] else [input_str[0...split_index], input_str[(split_index + 1)..-1]] end end |