Class: TE3270::Emulators::Quick3270
- Inherits:
-
Object
- Object
- TE3270::Emulators::Quick3270
- Defined in:
- lib/te3270/emulators/quick3270.rb
Overview
This class has the code necessary to communicate with the terminal emulator called Quick3270. You can use this emulator by providing the :quick
parameter to the constructor of your screen object or by passing the same value to the emulator_for
method on the TE3270
module.
Instance Attribute Summary collapse
-
#max_wait_time ⇒ Object
writeonly
Sets the attribute max_wait_time.
-
#session_file ⇒ Object
writeonly
Sets the attribute session_file.
-
#visible ⇒ Object
writeonly
Sets the attribute visible.
Instance Method Summary collapse
-
#connect {|_self| ... } ⇒ Object
Creates a method to connect to Quick System.
-
#disconnect ⇒ Object
Disconnects the Quick System connection.
-
#get_string(row, column, length) ⇒ String
Extracts text of specified length from a start point.
-
#put_string(str, row, column) ⇒ Object
Puts string at the coordinates specified.
-
#screenshot(filename) ⇒ Object
Creates a method to take screenshot of the active screen.
-
#send_keys(keys) ⇒ Object
Sends keystrokes to the host, including function keys.
-
#text ⇒ String
Returns the text of the active screen.
-
#wait_for_host(seconds) ⇒ Object
Waits for the host to not send data for a specified number of seconds.
-
#wait_for_string(str, row, column) ⇒ Object
Wait for the string to appear at the specified location.
-
#wait_until_cursor_at(row, column) ⇒ Object
Waits until the cursor is at the specified location.
Instance Attribute Details
#max_wait_time=(value) ⇒ Object
Sets the attribute max_wait_time
17 18 19 |
# File 'lib/te3270/emulators/quick3270.rb', line 17 def max_wait_time=(value) @max_wait_time = value end |
#session_file=(value) ⇒ Object (writeonly)
Sets the attribute session_file
17 18 19 |
# File 'lib/te3270/emulators/quick3270.rb', line 17 def session_file=(value) @session_file = value end |
#visible=(value) ⇒ Object
Sets the attribute visible
17 18 19 |
# File 'lib/te3270/emulators/quick3270.rb', line 17 def visible=(value) @visible = value end |
Instance Method Details
#connect {|_self| ... } ⇒ Object
Creates a method to connect to Quick System. This method expects a block in which certain platform specific values can be set. Quick can take the following parameters.
-
session_file - this value is required and should be the filename of the session.
-
visible - determines if the emulator is visible or not. If not set it will default to
true
.
33 34 35 36 37 38 |
# File 'lib/te3270/emulators/quick3270.rb', line 33 def connect start_quick_system yield self if block_given? raise "The session file must be set in a block when calling connect with the Quick3270 emulator." if @session_file.nil? establish_session end |
#disconnect ⇒ Object
Disconnects the Quick System connection
43 44 45 46 |
# File 'lib/te3270/emulators/quick3270.rb', line 43 def disconnect session.Disconnect system.Application.Quit end |
#get_string(row, column, length) ⇒ String
Extracts text of specified length from a start point.
56 57 58 |
# File 'lib/te3270/emulators/quick3270.rb', line 56 def get_string(row, column, length) screen.GetString(row, column, length) end |
#put_string(str, row, column) ⇒ Object
Puts string at the coordinates specified.
67 68 69 70 71 |
# File 'lib/te3270/emulators/quick3270.rb', line 67 def put_string(str, row, column) screen.MoveTo(row, column) screen.PutString(str) quiet_period end |
#screenshot(filename) ⇒ Object
Creates a method to take screenshot of the active screen. If you have set the :visible
property to false it will be made visible prior to taking the screenshot and then changed to invisible after.
120 121 122 123 124 125 126 |
# File 'lib/te3270/emulators/quick3270.rb', line 120 def screenshot(filename) File.delete(filename) if File.exists?(filename) system.Visible = true unless visible title = system.WindowTitle Win32::Screenshot::Take.of(:window, title: title).write(filename) system.Visible = false unless visible end |
#send_keys(keys) ⇒ Object
Sends keystrokes to the host, including function keys.
78 79 80 81 |
# File 'lib/te3270/emulators/quick3270.rb', line 78 def send_keys(keys) screen.SendKeys(keys) quiet_period end |
#text ⇒ String
Returns the text of the active screen
133 134 135 136 137 138 139 |
# File 'lib/te3270/emulators/quick3270.rb', line 133 def text rows = screen.Rows columns = screen.Cols result = '' rows.times { |row| result += "#{screen.GetString(row+1, 1, columns)}\\n" } result end |
#wait_for_host(seconds) ⇒ Object
Waits for the host to not send data for a specified number of seconds
99 100 101 |
# File 'lib/te3270/emulators/quick3270.rb', line 99 def wait_for_host(seconds) screen.WaitHostQuiet(seconds * 1000) end |
#wait_for_string(str, row, column) ⇒ Object
Wait for the string to appear at the specified location
90 91 92 |
# File 'lib/te3270/emulators/quick3270.rb', line 90 def wait_for_string(str, row, column) screen.WaitForString(str, row, column) end |
#wait_until_cursor_at(row, column) ⇒ Object
Waits until the cursor is at the specified location.
109 110 111 |
# File 'lib/te3270/emulators/quick3270.rb', line 109 def wait_until_cursor_at(row, column) screen.WaitForCursor(row, column) end |