Add basic Client class
This commit is contained in:
parent
fe47e27d98
commit
6e90225c9d
@ -5,6 +5,7 @@ require 'uh'
|
|||||||
|
|
||||||
require 'uh/wm/actions_handler'
|
require 'uh/wm/actions_handler'
|
||||||
require 'uh/wm/cli'
|
require 'uh/wm/cli'
|
||||||
|
require 'uh/wm/client'
|
||||||
require 'uh/wm/dispatcher'
|
require 'uh/wm/dispatcher'
|
||||||
require 'uh/wm/env'
|
require 'uh/wm/env'
|
||||||
require 'uh/wm/manager'
|
require 'uh/wm/manager'
|
||||||
|
24
lib/uh/wm/client.rb
Normal file
24
lib/uh/wm/client.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
module Uh
|
||||||
|
module WM
|
||||||
|
class Client
|
||||||
|
attr_reader :window
|
||||||
|
|
||||||
|
def initialize window, geo = nil
|
||||||
|
@window = window
|
||||||
|
@geo = geo
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"<#{wname}> (#{wclass}) #{@geo} win: #{@window}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def wname
|
||||||
|
@wname ||= @window.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def wclass
|
||||||
|
@wclass ||= @window.wclass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
39
spec/uh/wm/client_spec.rb
Normal file
39
spec/uh/wm/client_spec.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
module Uh
|
||||||
|
module WM
|
||||||
|
RSpec.describe Client do
|
||||||
|
let(:geo) { Geo.new(0, 0, 640, 480) }
|
||||||
|
let(:window) { double 'window', to_s: 'wid', name: 'wname', wclass: 'wclass' }
|
||||||
|
subject(:client) { described_class.new window, geo }
|
||||||
|
|
||||||
|
describe '#to_s' do
|
||||||
|
it 'includes window name' do
|
||||||
|
expect(client.to_s).to include 'wname'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes window class' do
|
||||||
|
expect(client.to_s).to include 'wclass'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes geo' do
|
||||||
|
expect(client.to_s).to include geo.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes window id' do
|
||||||
|
expect(client.to_s).to include 'wid'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#wname' do
|
||||||
|
it 'returns the window name' do
|
||||||
|
expect(client.wname).to eq window.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#wclass' do
|
||||||
|
it 'returns the window class' do
|
||||||
|
expect(client.wclass).to eq window.wclass
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user