Class: Rundoc::CodeCommand::Website::VisitRunner
- Inherits:
-
Object
- Object
- Rundoc::CodeCommand::Website::VisitRunner
- Defined in:
- lib/rundoc/code_command/website/visit.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #call(env = {}) ⇒ Object
- #driver ⇒ Object
-
#initialize(user_args:, render_command:, render_result:, io:, contents: nil) ⇒ VisitRunner
constructor
A new instance of VisitRunner.
- #to_md(env = {}) ⇒ Object
Constructor Details
#initialize(user_args:, render_command:, render_result:, io:, contents: nil) ⇒ VisitRunner
Returns a new instance of VisitRunner.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rundoc/code_command/website/visit.rb', line 21 def initialize(user_args:, render_command:, render_result:, io:, contents: nil) @name = user_args.name @url = user_args.url @scroll = user_args.scroll @height = user_args.height @width = user_args.width @visible = user_args.visible @max_attempts = user_args.max_attempts @io = io @contents = contents.dup if contents && !contents.empty? end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
19 20 21 |
# File 'lib/rundoc/code_command/website/visit.rb', line 19 def contents @contents end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
19 20 21 |
# File 'lib/rundoc/code_command/website/visit.rb', line 19 def io @io end |
Instance Method Details
#call(env = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rundoc/code_command/website/visit.rb', line 50 def call(env = {}) = "Visting: #{@url}" << "and executing:\n#{contents}" unless contents.nil? || contents.empty? io.puts driver.visit(@url, max_attempts: @max_attempts) if @url driver.scroll(@scroll) if @scroll return "" if contents.nil? || contents.empty? driver.safe_eval(contents, env) "" end |
#driver ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rundoc/code_command/website/visit.rb', line 33 def driver @driver ||= Driver.new( name: @name, url: @url, height: @height, width: @width, visible: @visible, io: io ).tap do |driver| Driver.add(@name, driver) end end |
#to_md(env = {}) ⇒ Object
46 47 48 |
# File 'lib/rundoc/code_command/website/visit.rb', line 46 def to_md(env = {}) "" end |