use OpenStruct instead of returning a hash value

When we created a Packet object before using
Packet.read would return a hash. Instead, return
an OpenStruct object which makes accessing
parameters easier
This commit is contained in:
Richard Ramsden 2012-05-19 13:14:47 -07:00
parent 13f78a85a0
commit 736e4d179b
3 changed files with 9 additions and 6 deletions

View file

@ -5,6 +5,7 @@ module X11
class AuthorizationError < X11Error; end
class Display
attr_accessor :socket
# Open a connection to the specified display (numbered from 0) on the specified host
def initialize(target = ENV['DISPLAY'])
@ -25,7 +26,7 @@ module X11
end
def screens
@internal[:screens].map do |s|
@internal.screens.map do |s|
Screen.new(self, s)
end
end

View file

@ -50,7 +50,7 @@ module X11
end
end
values
OpenStruct.new(values)
end
def field(*args)
@ -92,9 +92,7 @@ module X11
s.type == :unused or s.type == :length
end
end
end
end
end
end

View file

@ -8,11 +8,15 @@ module X11
end
def width
@internal[:width_in_pixels]
@internal.width_in_pixels
end
def height
@internal[:height_in_pixels]
@internal.height_in_pixels
end
def to_s
"#<X11::Screen(#{id}) width=#{width} height=#{height}>"
end
end
end