Created
September 7, 2012 20:16
-
-
Save D3MZ/3669259 to your computer and use it in GitHub Desktop.
dn work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def split_to_array | |
encoding_options = { | |
:invalid => :replace, # Replace invalid byte sequences | |
:undef => :replace, # Replace anything not defined in ASCII | |
:replace => ' ', # Use a blank for those replacements | |
:universal_newline => true # Always break lines with \n | |
} | |
string = self.encode(Encoding.find('ASCII'), encoding_options) | |
string = string.split("\n").delete_if {|x| x.empty?} | |
string.length > 2 ? string : string.split(". ") | |
end | |
end | |
s = "Directions:\n\nPlace all ingredients together in a microwave safe dish. Cover and cook for 5 minutes or until apples are tender. Stir and serve!\n\n\n" | |
s.split_to_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment