Class | SDL4R::SdlBinary |
In: |
lib/sdl4r/sdl_binary.rb
|
Parent: | Object |
Represents a binary value.
This class was introduced to avoid the confusion between a Ruby String and a binary literal.
bytes | [RW] |
Decodes the specified base-64 encoded string and returns a corresponding SdlBinary instance. s might not include the conventional starting and ending square brackets.
# File lib/sdl4r/sdl_binary.rb, line 57 def self.decode64(s) s = s.delete("\n\r\t ") binary = Base64.decode64(s) if binary.empty? and not s.empty? raise ArgumentError, "bad binary literal" end return SdlBinary.new(binary) end
value: a String containing the bytes
# File lib/sdl4r/sdl_binary.rb, line 33 def initialize(bytes) @bytes = bytes end