mirror of
https://github.com/vidarh/ruby-x11
synced 2024-12-26 09:59:02 +01:00
add docs for encode.rb
This commit is contained in:
parent
8b74338037
commit
75b7bde359
1 changed files with 11 additions and 2 deletions
|
@ -1,7 +1,16 @@
|
|||
# This module is used for encoding Ruby Objects to binary
|
||||
# data. The types Int8, Int16, etc. are data-types defined
|
||||
# in the X11 protocol. We wrap each data-type in a lambda expression
|
||||
# which gets evaluated when a packet is created.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# Int8.call(255) => "\xFF"
|
||||
# String8.call("hello") => "hxello\u0000\u0000\u0000"
|
||||
|
||||
module X11
|
||||
# used to encode plain data into
|
||||
# binary data which the X11 protocol can read
|
||||
module Encode
|
||||
# Takes an object and uses Array#pack to
|
||||
# convert it into binary data
|
||||
def self.pack(a)
|
||||
lambda {|value| [value].pack(a)}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue