Class: Repla::View

Inherits:
Window show all
Defined in:
lib/repla/lib/view.rb,
lib/repla/lib/view/resources.rb,
lib/repla/lib/view/javascript.rb

Overview

View

Direct Known Subclasses

Dependencies::View, Print::View, REPL::View

Constant Summary

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

Class Method Summary collapse

Instance Method Summary collapse

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

#initialize(window_id = nil, view_id = nil) ⇒ View

Properties



9
10
11
12
# File 'lib/repla/lib/view.rb', line 9

def initialize(window_id = nil, view_id = nil)
  super(window_id)
  @view_id = view_id
end

Class Method Details

.javascript_function(function, arguments = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/repla/lib/view/javascript.rb', line 13

def self.javascript_function(function, arguments = nil)
  function = function.dup
  function << '('

  if arguments
    arguments.each do |argument|
      function << if argument
                    argument.javascript_argument
                  else
                    'null'
                  end
      function << ', '
    end
    function = function[0...-2]
  end

  function << ');'
end

Instance Method Details

#do_javascript_function(function, arguments = nil) ⇒ Object



8
9
10
11
# File 'lib/repla/lib/view/javascript.rb', line 8

def do_javascript_function(function, arguments = nil)
  javascript = self.class.javascript_function(function, arguments)
  do_javascript(javascript)
end

#view_idObject



14
15
16
# File 'lib/repla/lib/view.rb', line 14

def view_id
  @view_id ||= ENV.key?(SPLIT_ID_KEY) ? ENV[SPLIT_ID_KEY] : split_id
end