Class: X11::Type::BaseType

Inherits:
Object
  • Object
show all
Defined in:
lib/X11/type.rb

Direct Known Subclasses

Int16, Int32, Int8, Uint16, Uint32, Uint8

Class Method Summary collapse

Class Method Details

.config(d, b) ⇒ Object



12
# File 'lib/X11/type.rb', line 12

def self.config(d,b) = (@directive, @bytesize = d,b)

.from_packet(sock) ⇒ Object



27
# File 'lib/X11/type.rb', line 27

def self.from_packet(sock) = unpack(sock.read(size))

.pack(x, dpy) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/X11/type.rb', line 14

def self.pack(x, dpy)
  if x.is_a?(Symbol)
    if (t = X11::Form.const_get(x)) && t.is_a?(Numeric)
      x = t
    end
  end
  [x].pack(@directive)
rescue TypeError
  raise "Expected #{self.name}, got #{x.class} (value: #{x})"
end

.sizeObject



26
# File 'lib/X11/type.rb', line 26

def self.size = @bytesize

.unpack(x) ⇒ Object



25
# File 'lib/X11/type.rb', line 25

def self.unpack(x) = x.nil? ? nil  : x.unpack1(@directive)