Ruby is like this:
class User
attr_accessor :username, :username_appearance, :password, :email
def initialize(username, password, email)
@username, @password, @email = username, password, email
@username_appearance = @username
@login_status = 0
@wall = []
@title_of_wall = "Wall"
end
def login(username, password)
if (@username.downcase == username.downcase and @password.downcase == password.downcase)
if (@login_status == 0)
puts "You have successfully logged in as #{@username}."
@login_status = 1
else
puts "You are already logged in as #{@username}."
end
else
if (@login_status == 0)
puts "You have unsuccessfully logged in as #{@username}."
else
puts "You are already logged in as #{@username}."
end
end
end
def logout
if (@login_status == 0)
puts "You aren't logged in yet."
else
puts "You are logged out."
@login_status = 0
end
end
def comment(name, body)
@wall.push("#{name}: #{body}")
end
def view_wall()
if (@login_status == 0)
puts "You cannot view your wall until you login."
else
puts "\n"
puts "-------#{@title_of_wall}-------"
for comment in @wall
puts comment
end
puts "\n"
end
end
def preferences()
if (@login_status == 0)
puts "You cannot change your preferences until you login."
else
puts "You can only change the title of your wall. Please type titlewall to change it."
change_choice = gets.chomp
if (change_choice =~ /titlewall/i)
puts "What would you like to call it?"
@title_of_wall = gets.chomp
elsif (change_choice =~ /email/i)
puts "What would you like your email to be?"
@email = gets.chomp
elsif (change_choice =~ /username_appearance/i)
puts "How would you like your username to appear?"
@username_appearance = gets.chomp
end
end
end
end
user = User.new("deoxy99", "", "appleapple24@gmail.com")
By the way, Ruby on Rails is Rails (HTML) combined with Ruby... difficult to install, difficult to code (sometimes).
But Ruby itself is easy to code.