Module: Playground::ScriptsHelper

Defined in:
app/helpers/playground/scripts_helper.rb

Constant Summary collapse

MAX_SELECT_BOX_SIZE =
15

Instance Method Summary collapse

Instance Method Details

#script_options(scripts) ⇒ Object



9
10
11
12
13
14
15
# File 'app/helpers/playground/scripts_helper.rb', line 9

def script_options(scripts)
  options = scripts
    .map { |path| [script_label(path), url(path)] }
    .unshift(["New script", new_script_path(format: :turbo_stream)])

  options_for_select options
end

#script_size(scripts) ⇒ Object



5
6
7
# File 'app/helpers/playground/scripts_helper.rb', line 5

def script_size(scripts)
  [MAX_SELECT_BOX_SIZE, scripts.length + 1].min
end