Class: Repla::REPL::View

Inherits:
View show all
Defined in:
lib/repla/repl/lib/view.rb

Overview

REPL view

Constant Summary collapse

ROOT_ACCESS_DIRECTORY =
File.join(__dir__, '../../')
HTML_DIRECTORY =
File.join(__dir__, '../html/')
VIEW_TEMPLATE =
File.join(HTML_DIRECTORY, 'index.html')
ADD_INPUT_JAVASCRIPT_FUNCTION =
'WcREPL.addInput'.freeze
ADD_OUTPUT_JAVASCRIPT_FUNCTION =
'WcREPL.addOutput'.freeze

Constants inherited from Window

Window::CLOSEWINDOW_SCRIPT, Window::DOJAVASCRIPT_SCRIPT, Window::LOADWITHROOTACCESSDIRECTORY_SCRIPT, Window::LOAD_SCRIPT, Window::LOAD_URL_CACHE_SCRIPT, Window::LOAD_URL_SCRIPT, Window::READ_FROM_STANDARD_INPUT_SCRIPT

Instance Attribute Summary

Attributes inherited from Window

#root_access_directory_path

Instance Method Summary collapse

Methods inherited from View

#do_javascript_function, javascript_function, #view_id

Methods inherited from Window

#close, #dark_mode, #do_javascript, #load_file, #load_url, #read_from_standard_input, #split_id, #split_id_last, #window_id

Constructor Details

#initializeView

Returns a new instance of View.



8
9
10
11
12
13
14
# File 'lib/repla/repl/lib/view.rb', line 8

def initialize
  super
  self.root_access_directory_path = File.expand_path(
    ROOT_ACCESS_DIRECTORY
  )
  load_file(VIEW_TEMPLATE)
end

Instance Method Details

#add_input(input) ⇒ Object



17
18
19
# File 'lib/repla/repl/lib/view.rb', line 17

def add_input(input)
  do_javascript_function(ADD_INPUT_JAVASCRIPT_FUNCTION, [input])
end

#add_output(output) ⇒ Object



22
23
24
# File 'lib/repla/repl/lib/view.rb', line 22

def add_output(output)
  do_javascript_function(ADD_OUTPUT_JAVASCRIPT_FUNCTION, [output])
end