class RailsNewApp::Screen

Attributes

config[R]

Public Class Methods

clean_name() click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 10
def self.clean_name
  to_s.gsub("Screen", "").gsub("RailsNewApp::", "")
end
default() click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 58
def self.default
  ""
end
key() click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 14
def self.key
  clean_name.underscore.to_sym
end
new(config) click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 5
def initialize(config)
  @config = config
  @input = ""
end

Public Instance Methods

after_valid() click to toggle source

after valid message

# File lib/rails-new-app/screens/screen.rb, line 50
def after_valid
end
clean_input(input) click to toggle source

clean the input if needed before validations

# File lib/rails-new-app/screens/screen.rb, line 39
def clean_input(input)
  input.strip
end
next_step() click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 62
def next_step
  :menu
end
process_user_input(input) click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 22
def process_user_input(input)
  if validate_user_input(input)
    [next_step, return_value]
  else
    [:rerender, nil]
  end
end
return_value() click to toggle source

process @input to return a different value

# File lib/rails-new-app/screens/screen.rb, line 54
def return_value
  @input
end
screen_text() click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 18
def screen_text
  raise "screen text must be re-defined"
end
valid?(input) click to toggle source

validate the input

# File lib/rails-new-app/screens/screen.rb, line 44
def valid?(input)
  @error = false
  true
end
validate_user_input(input) click to toggle source
# File lib/rails-new-app/screens/screen.rb, line 30
def validate_user_input(input)
  input = clean_input(input)
  if valid?(input)
    @input = input
    true
  end
end