Module: OmniAI::Tools::Browser::Formatters::ActionFormatter
- Defined in:
- lib/omniai/tools/browser/formatters/action_formatter.rb
Overview
Handles formatting of action elements (buttons, links)
Class Method Summary collapse
- .format_action_element(action) ⇒ Object
- .format_actions(actions) ⇒ Object
- .get_action_selector(action) ⇒ Object
Class Method Details
.format_action_element(action) ⇒ Object
20 21 22 23 24 |
# File 'lib/omniai/tools/browser/formatters/action_formatter.rb', line 20 def format_action_element(action) text = action.text.strip selector = get_action_selector(action) " • #{text} (#{selector})\n" end |
.format_actions(actions) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/omniai/tools/browser/formatters/action_formatter.rb', line 11 def format_actions(actions) result = "⚡ Available Actions:\n" actions.first(5).each do |action| result += format_action_element(action) end result += " ... and #{actions.size - 5} more\n" if actions.size > 5 result += "\n" end |
.get_action_selector(action) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/omniai/tools/browser/formatters/action_formatter.rb', line 26 def get_action_selector(action) return action["id"] if action["id"] && !action["id"].empty? return "text:#{action.text.strip}" if action.text.strip.length > 2 return action["class"].split.first if action["class"] "css-needed" end |