mirror of
https://github.com/vidarh/ruby-x11
synced 2024-12-26 09:59:02 +01:00
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:
parent
13f78a85a0
commit
736e4d179b
3 changed files with 9 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue