Class: Studium::CurriculumDisplayer

Inherits:
Sinatra::Base
  • Object
show all
Includes:
HtmlTags::BaseModule, Colours
Defined in:
lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb

Overview

Studium::CurriculumDisplayer

Constant Summary collapse

USE_THIS_PORT =
#

USE_THIS_PORT

#
'4575'

Constants included from Colours

Studium::Colours::COLOURS

Instance Method Summary collapse

Methods included from Colours

#bold_blue, #bold_red, #bold_yellow, cadetblue, #cadetblue, #chartreuse, #coral, coral, #cornflowerblue, cornflowerblue, crimson, #cyan, cyan, darkgoldenrod, #darkgoldenrod, #darkgray, darkgreen, darkolivegreen, darkseagreen, #darkslateblue, darkslateblue, #darkslategray, darkslategray, #darkturquoise, darkturquoise, #deepskyblue, deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #erev, #ewarn, #forestgreen, forestgreen, gold, #goldenrod, goldenrod, #grey, grey, indianred, #indianred, khaki, #khaki, lawngreen, #lawngreen, lightblue, lightgreen, lightsalmon, #lightseagreen, lightseagreen, lightskyblue, #lightskyblue, #lightslategray, lightslategray, #lightsteelblue, lime, #lime, limegreen, #limegreen, #mediumaquamarine, mediumaquamarine, #mediumorchid, #mediumpurple, mediumpurple, #mediumseagreen, mediumseagreen, #mediumslateblue, mediumslateblue, #mediumspringgreen, mediumspringgreen, #mediumturquoise, mediumturquoise, #oldlace, olive, #olive, olivedrab, #olivedrab, orange, orangered, #orchid, orchid, palegreen, #palegreen, paleturquoise, #paleturquoise, palevioletred, #papayawhip, peru, #peru, plum, #plum, #powderblue, powderblue, rev, #rev?, royalblue, saddlebrown, #saddlebrown, #sandybrown, sandybrown, sdir, #sdir, seagreen, #seagreen, sfancy, #sfancy, sfile, #sfile, #simp, simp, #skyblue, skyblue, slateblue, #slategray, slategray, springgreen, #springgreen, #steelblue, steelblue, #swarn, swarn, #tan, tan, teal, #teal, #tomato, tomato, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow, yellowgreen, #yellowgreen

Constructor Details

#initializeCurriculumDisplayer

#

initialize

#


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 34

def initialize
  super()
  reset
  if HtmlTags::BaseModule.is_on_roebe?
    require 'open'
    # ===================================================================== #
    # Tell us which port will be used:
    # ===================================================================== #
    target = "http://localhost:#{USE_THIS_PORT}/"
    e sfancy(target)
    Thread.new {
      Open.in_browser(target) {{ delay: '1.0 seconds' }}
    }
  end
end

Instance Method Details

#html_endObject

#

html_end

#


107
108
109
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 107

def html_end
  '</body></html>'
end

#html_startObject

#

html_start

#


100
101
102
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 100

def html_start
  '<html><head></head><body>'
end

#resetObject

#

reset

#


138
139
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 138

def reset
end

#return_available_curriculaObject

#

return_available_curricula

#


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 114

def return_available_curricula
  array = Studium.available_curricula?.map {|entry|
    entry = entry.to_s
    if entry.include? '_'
      entry.tr!('_',' ')
    end
    entry[0,1] = entry[0,1].upcase
    entry
  }
  string = ''.dup
  array.each {|entry|
    # ===================================================================== #
    # Use the <a> tag next:
    # ===================================================================== #
    string << HtmlTags.a(entry, content: entry, css_style: 'padding-left:2em')+
              HtmlTags.br+
              "\n"
  }
  string
end

#return_root_stringObject

#

return_root_string

#


62
63
64
65
66
67
68
69
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 62

def return_root_string
  '<html>'+
  '<title>Displaying a curriculum</title>'+
  '<body>'+
  show_the_available_links+
  '</body>'+
  '</html>'
end

#runObject

#

run

#


144
145
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 144

def run
end
#
#


74
75
76
77
78
79
# File 'lib/studium/www/sinatra/curriculum_displayer/curriculum_displayer.rb', line 74

def show_the_available_links
  available_curricula = return_available_curricula
  p('Click on any of the following links to view the curriculum
  that you wish to see.')+
  available_curricula
end