Class: Waw::Routing::Redirect

Inherits:
RoutingRule show all
Defined in:
lib/waw/routing/redirect.rb

Overview

Redirect routing

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Redirect

Creates a redirection rule instance



7
8
9
# File 'lib/waw/routing/redirect.rb', line 7

def initialize(opts = {})
  @opts = opts
end

Instance Method Details

#apply_on_browser(result, browser) ⇒ Object

Forces the browser to refresh



12
13
14
# File 'lib/waw/routing/redirect.rb', line 12

def apply_on_browser(result, browser)
  browser.location = @opts[:url]
end

#generate_js_code(result, align = 0) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/waw/routing/redirect.rb', line 16

def generate_js_code(result, align=0)
  if @opts[:url]
    " "*align + "window.location = \"#{@opts[:url]}\";"
  else
    " "*align + "window.location = data[1];"
  end
end