module WSOC::Helpers::Course

Public Instance Methods

course_dir() click to toggle source

The course directory.

@return [String]

The course directory.

@example

course_dir
# => "/course/"

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 99
def course_dir
  "#{Config::COURSE_DIR}/"
end
course_fail() click to toggle source

The full course failure URL.

@return [String]

The remote course failure URL.

@example

course_fail
# => "http://localhost:8080/course/fail"

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 131
def course_fail
  remote_url Config::COURSE_FAIL_PATH
end
course_page(name) click to toggle source

Renders a course page.

@param [Symbol] name

The name of the course page.

@return [String]

The rendered page.

@example

course_page :course_start

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 41
def course_page(name)
  erb name, :layout => false
end
course_start() click to toggle source

The full course starting URL.

@return [String]

The remote course starting URL.

@example

course_start
# => "http://localhost:8080/course/start.html"

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 115
def course_start
  remote_url Config::COURSE_START_PATH
end
remote_url(path) click to toggle source

Generates a remote URL containing a given path.

@param [String] path

The path to include within the URL.

@return [String]

The remote URL.

@example

remote_url '/course/redirects/start.html'
# => "http://localhost:8080/course/redirects/start.html"

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 79
def remote_url(path)
  s = "#{request.scheme}://#{request.host}"
  s << ":#{request.port}" if request.port != 80
  s << path

  return s
end
specs() click to toggle source

The specs for the course.

@return [Array<Hash>]

The Array of specs for each URL within the course.

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 143
def specs
  CourseSpecs.map(request.host,request.port)
end
title_for(*names) click to toggle source

Renders a title string.

@param [Array] names

The names to put into the title.

@return [String]

The title.

@example

title_for 'HTTP Redirects'
# => "Web Spider Obstacle Course :: HTTP Redirects"

@since 0.1.0

# File lib/wsoc/helpers/course.rb, line 60
def title_for(*names)
  (['Web Spider Obstacle Course'] + names).join(' :: ')
end