Class: Dictionaries::Sinatra

Inherits:
Sinatra::Base
  • Object
show all
Includes:
Colours, Colours::E
Defined in:
lib/dictionaries/sinatra/app.rb,
lib/dictionaries/sinatra/english_to_german.rb

Constant Summary collapse

USE_THIS_PORT =
#

USE_THIS_PORT

#
'5252'

Instance Method Summary collapse

Constructor Details

#initialize(i = ARGV) ⇒ Sinatra

#

initialize

#

36
37
38
39
40
41
42
# File 'lib/dictionaries/sinatra/app.rb', line 36

def initialize(
    i = ARGV
  )
  super()
  reset
  consider_opening_the_page_in_the_browser(i)
end

Instance Method Details

#consider_opening_the_page_in_the_browser(shall_we_open_the_page_in_the_browser = ::Dictionaries.is_on_roebe?) ⇒ Object

#

consider_opening_the_page_in_the_browser

#

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/dictionaries/sinatra/app.rb', line 53

def consider_opening_the_page_in_the_browser(
    shall_we_open_the_page_in_the_browser = ::Dictionaries.is_on_roebe?
  )
  case shall_we_open_the_page_in_the_browser
  # ======================================================================= #
  # === :do_not_open_in_the_browser
  # ======================================================================= #
  when :do_not_open_in_the_browser,
       :dont_connect,
       :dont
    shall_we_open_the_page_in_the_browser = false
  end
  if shall_we_open_the_page_in_the_browser
    begin
      require 'open'
    rescue LoadError; end
    # ===================================================================== #
    # Tell us which port will be used:
    # ===================================================================== #
    target = "http://localhost:#{USE_THIS_PORT}/"
    e sfancy(target)
    Thread.new {
      sleep 0.8
      Open.in_browser(target)
    }
  end
end

#html_header_default_title_and_start_of_the_body_tagObject

#

html_header_default_title_and_start_of_the_body_tag

#

49
50
51
# File 'lib/dictionaries/sinatra/english_to_german.rb', line 49

def html_header_default_title_and_start_of_the_body_tag
  return Dictionaries::HelperModule.html_header_default_title_and_start_of_the_body_tag
end

#resetObject

#

reset (reset tag)

#

47
48
# File 'lib/dictionaries/sinatra/app.rb', line 47

def reset
end

#return_english_to_german_formObject

#

return_english_to_german_form

#

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dictionaries/sinatra/english_to_german.rb', line 28

def return_english_to_german_form
  route_to_this_action = '/english_to_german/'
  html_header_default_title_and_start_of_the_body_tag+
  h5('Input an english word to see the translation.')+
  div(css_style: 'padding: 0.1em') {
    p(
      '<b>Enter the word here:</b>',
      css_style: 'padding: 0.15em'
    )+
    form(action: route_to_this_action,
             id: 'english_to_german',
      css_style: 'margin-left:1em; margin-top:2px') {
      '<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px"><br>'+
      return_search_button
    }
  }
end

#return_search_buttonObject

#

return_search_button

#

56
57
58
# File 'lib/dictionaries/sinatra/english_to_german.rb', line 56

def return_search_button
  return Dictionaries::HelperModule.return_search_button
end