BaseHangul::Utils
Helper methods for BaseHangul.
Class methods
chunks(str, size)
Slice a string into chunks of a given size.
str - The String to slice. size - The Integer max size of each chunk.
Examples
chunks("foo", 1)
=> ["f", "o", "o"]
chunks("foobarbaz", 3)
=> ["foo", "bar", "baz"]
chunks("abcd1234AB", 4)
=> ["abcd", "1234", "AB"]
chunks("", 1)
=> []
Returns an Array of Slice of chunked Strings. Raises ArgumentError if the size is smaller than or equal to 0.
to_bin(str)
Format String bytes to binary form. If the length of each binary string is smaller than 8, it pads '0' at the left to make its length to 8.
str - A String to convert.
Returns a binary form String which of the length is multiple of 8.