Class: Rundoc::CodeCommand::Website::Visit

Inherits:
Rundoc::CodeCommand show all
Defined in:
lib/rundoc/code_command/website/visit.rb

Constant Summary

Constants inherited from Rundoc::CodeCommand

NEWLINE, RUNDOC_DEFAULT_ERB_BINDING, RUNDOC_ERB_BINDINGS

Instance Attribute Summary

Attributes inherited from Rundoc::CodeCommand

#command, #contents, #keyword, #original_args, #render_command, #render_result

Instance Method Summary collapse

Methods inherited from Rundoc::CodeCommand

#push

Constructor Details

#initialize(name:, url: nil, scroll: nil, height: 720, width: 1024, visible: false, max_attempts: 3) ⇒ Visit

Returns a new instance of Visit.



5
6
7
8
9
10
11
12
13
# File 'lib/rundoc/code_command/website/visit.rb', line 5

def initialize(name:, url: nil, scroll: nil, height: 720, width: 1024, visible: false, max_attempts: 3)
  @name = name
  @url = url
  @scroll = scroll
  @height = height
  @width = width
  @visible = visible
  @max_attempts = max_attempts
end

Instance Method Details

#call(env = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rundoc/code_command/website/visit.rb', line 31

def call(env = {})
  message = "Visting: #{@url}"
  message << "and executing:\n#{contents}" unless contents.nil? || contents.empty?

  puts message

  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

#driverObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rundoc/code_command/website/visit.rb', line 15

def driver
  @driver ||= Driver.new(
    name: @name,
    url: @url,
    height: @height,
    width: @width,
    visible: @visible
  ).tap do |driver|
    Driver.add(@name, driver)
  end
end

#hidden?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/rundoc/code_command/website/visit.rb', line 46

def hidden?
  true
end

#not_hidden?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/rundoc/code_command/website/visit.rb', line 50

def not_hidden?
  !hidden?
end

#to_md(env = {}) ⇒ Object



27
28
29
# File 'lib/rundoc/code_command/website/visit.rb', line 27

def to_md(env = {})
  ""
end