mirror of
https://github.com/vidarh/ruby-x11
synced 2024-12-27 09:59:21 +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 AuthorizationError < X11Error; end
|
||||||
|
|
||||||
class Display
|
class Display
|
||||||
|
attr_accessor :socket
|
||||||
|
|
||||||
# Open a connection to the specified display (numbered from 0) on the specified host
|
# Open a connection to the specified display (numbered from 0) on the specified host
|
||||||
def initialize(target = ENV['DISPLAY'])
|
def initialize(target = ENV['DISPLAY'])
|
||||||
|
@ -25,7 +26,7 @@ module X11
|
||||||
end
|
end
|
||||||
|
|
||||||
def screens
|
def screens
|
||||||
@internal[:screens].map do |s|
|
@internal.screens.map do |s|
|
||||||
Screen.new(self, s)
|
Screen.new(self, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,7 @@ module X11
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
values
|
OpenStruct.new(values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def field(*args)
|
def field(*args)
|
||||||
|
@ -92,9 +92,7 @@ module X11
|
||||||
s.type == :unused or s.type == :length
|
s.type == :unused or s.type == :length
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,11 +8,15 @@ module X11
|
||||||
end
|
end
|
||||||
|
|
||||||
def width
|
def width
|
||||||
@internal[:width_in_pixels]
|
@internal.width_in_pixels
|
||||||
end
|
end
|
||||||
|
|
||||||
def height
|
def height
|
||||||
@internal[:height_in_pixels]
|
@internal.height_in_pixels
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#<X11::Screen(#{id}) width=#{width} height=#{height}>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue