class RailsNewApp::ChoiceScreen

Public Instance Methods

clean_input(input) click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 28
def clean_input(input)
  input.to_i
end
option() click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 7
def option
  options[@input - 1]
end
options() click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 3
def options
  []
end
return_value() click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 42
def return_value
  lower = lowercase_keys[@input - 1]

  {
    option_number: @input,
    name: option,
    key: lower
  }
end
screen_text() click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 11
def screen_text
  [].tap do |ls|
    ls << @error if @error
    ls << step_question
    ls << ""

    current = config[self.class.key] ? config[self.class.key][:option_number] : nil
    options.each_with_index do |op, idx|
      aux = idx + 1
      is_current = aux == current ? " (current)" : ""
      ls << "#{aux} ) #{op}#{is_current}"
    end
    ls << ""
    ls << "0 ) Back to menu"
  end.join("\n")
end
valid?(input) click to toggle source
# File lib/rails-new-app/screens/choice_screen.rb, line 32
def valid?(input)
  if options[input - 1]
    @error = false
    true
  else
    @error = "Invalid option, choose again:"
    false
  end
end