Class: TansParser::Element
- Inherits:
-
Struct
- Object
- Struct
- TansParser::Element
- Defined in:
- lib/tans_parser/element.rb
Overview
Describes a recognized UI element on the terminal screen.
Instance Attribute Summary collapse
-
#bg ⇒ Object
Returns the value of attribute bg.
-
#checked ⇒ Object
Returns the value of attribute checked.
-
#col ⇒ Object
Returns the value of attribute col.
-
#confidence ⇒ Object
Returns the value of attribute confidence.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#fg ⇒ Object
Returns the value of attribute fg.
-
#focused ⇒ Object
Returns the value of attribute focused.
-
#height ⇒ Object
Returns the value of attribute height.
-
#role ⇒ Object
Returns the value of attribute role.
-
#row ⇒ Object
Returns the value of attribute row.
-
#text ⇒ Object
Returns the value of attribute text.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #bounds ⇒ Object
- #checked? ⇒ Boolean
- #click ⇒ Object
- #confident? ⇒ Boolean
- #disabled? ⇒ Boolean
- #press_key(key) ⇒ Object
- #to_h ⇒ Object
- #type(text) ⇒ Object
Instance Attribute Details
#bg ⇒ Object
Returns the value of attribute bg
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def bg @bg end |
#checked ⇒ Object
Returns the value of attribute checked
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def checked @checked end |
#col ⇒ Object
Returns the value of attribute col
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def col @col end |
#confidence ⇒ Object
Returns the value of attribute confidence
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def confidence @confidence end |
#disabled ⇒ Object
Returns the value of attribute disabled
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def disabled @disabled end |
#fg ⇒ Object
Returns the value of attribute fg
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def fg @fg end |
#focused ⇒ Object
Returns the value of attribute focused
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def focused @focused end |
#height ⇒ Object
Returns the value of attribute height
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def height @height end |
#role ⇒ Object
Returns the value of attribute role
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def role @role end |
#row ⇒ Object
Returns the value of attribute row
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def row @row end |
#text ⇒ Object
Returns the value of attribute text
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def text @text end |
#width ⇒ Object
Returns the value of attribute width
5 6 7 |
# File 'lib/tans_parser/element.rb', line 5 def width @width end |
Instance Method Details
#bounds ⇒ Object
25 26 27 |
# File 'lib/tans_parser/element.rb', line 25 def bounds { row: row, col: col, width: width, height: height } end |
#checked? ⇒ Boolean
17 18 19 |
# File 'lib/tans_parser/element.rb', line 17 def checked? !!checked end |
#click ⇒ Object
29 30 31 |
# File 'lib/tans_parser/element.rb', line 29 def click { action: :click, target: self, row: row, col: col + (width / 2) } end |
#confident? ⇒ Boolean
41 42 43 |
# File 'lib/tans_parser/element.rb', line 41 def confident? confidence.nil? || confidence >= 0.5 end |
#disabled? ⇒ Boolean
21 22 23 |
# File 'lib/tans_parser/element.rb', line 21 def disabled? !!disabled end |
#press_key(key) ⇒ Object
37 38 39 |
# File 'lib/tans_parser/element.rb', line 37 def press_key(key) { action: :press_key, target: self, key: key } end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tans_parser/element.rb', line 45 def to_h { role: role, text: text, row: row, col: col, width: width, height: height, checked: checked, focused: focused, fg: fg, bg: bg, disabled: disabled, confidence: confidence, }.compact end |
#type(text) ⇒ Object
33 34 35 |
# File 'lib/tans_parser/element.rb', line 33 def type(text) { action: :type, target: self, row: row, col: col + (width / 2), text: text } end |