Class: TansParser::Selector
- Inherits:
-
Object
- Object
- TansParser::Selector
- Defined in:
- lib/tans_parser/selector.rb
Overview
Scans terminal state for recognized UI elements.
selector = Selector.new(state)
selector.get_by_text("OK") # => [Element, ...]
selector.get_by_role(:button) # => [Element, ...]
selector. # => [Element, ...]
selector.dialogs # => [Element, ...]
Constant Summary collapse
- TOP_LEFT_CORNERS =
/[┌┏┎┍]/- BOTTOM_LEFT_CORNERS =
%w[└ ┗ ┖ ┕ ╰ ╚].freeze
- BOTTOM_RIGHT_CORNERS =
%w[┘ ┛ ┚ ┙ ╯ ╝].freeze
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#buttons ⇒ Object
Convenience accessors.
- #checkboxes ⇒ Object
- #dialogs ⇒ Object
-
#get_by_role(role) ⇒ Object
Find elements by role.
-
#get_by_text(text) ⇒ Object
Find elements by visible text (partial match).
-
#initialize(state) ⇒ Selector
constructor
A new instance of Selector.
- #progress_bars ⇒ Object
- #statusbars ⇒ Object
Constructor Details
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
17 18 19 |
# File 'lib/tans_parser/selector.rb', line 17 def elements @elements end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
17 18 19 |
# File 'lib/tans_parser/selector.rb', line 17 def state @state end |
Instance Method Details
#buttons ⇒ Object
Convenience accessors
35 36 37 |
# File 'lib/tans_parser/selector.rb', line 35 def get_by_role(:button) end |
#checkboxes ⇒ Object
39 40 41 |
# File 'lib/tans_parser/selector.rb', line 39 def checkboxes get_by_role(:checkbox) end |
#dialogs ⇒ Object
43 44 45 |
# File 'lib/tans_parser/selector.rb', line 43 def dialogs get_by_role(:dialog) end |
#get_by_role(role) ⇒ Object
Find elements by role.
30 31 32 |
# File 'lib/tans_parser/selector.rb', line 30 def get_by_role(role) @elements.select { |e| e.role == role.to_sym } end |
#get_by_text(text) ⇒ Object
Find elements by visible text (partial match).
25 26 27 |
# File 'lib/tans_parser/selector.rb', line 25 def get_by_text(text) @elements.select { |e| e.text&.include?(text) } end |
#progress_bars ⇒ Object
51 52 53 |
# File 'lib/tans_parser/selector.rb', line 51 def get_by_role(:progress) end |
#statusbars ⇒ Object
47 48 49 |
# File 'lib/tans_parser/selector.rb', line 47 def get_by_role(:statusbar) end |