Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Bluefish, create a Ruby script named myscript.rb in your \"Working Directo

ID: 3679120 • Letter: U

Question

Using Bluefish, create a Ruby script named myscript.rb in your "Working Directory".

Create a class called Car with the following attributes in myscript.rb:

Make

Model

Year

Color

Create a new object from the Car class, that has the following properties:

Chevrolet

Corvette

2014

Red

Create a second new object from the Car class, that has the following properties:

Ford

Mustang

2006

Blue

Output the following information to the screen for each object, and append each object's properties to the end of each statement (e.g., "The make of car is:" car1.make):

"The make of car is:"

"The model of car is:"

"The year of car is:"

"The color of car is:"

So far, I have completed the first three tasks, I am just having trouble doing the last task.

This is what I have so far..

class Car
attr_accessor :make, :model, :year, :color

class Car_one < Car
end

class Car_two < Car
end

car_one = Car.new
car_one = "Chevrolet"
car_one = "Corvette"
car_one = 2014
car_one = "Red"

car_two = Car.new
car_two = "Ford"
car_two = "Mustang"
car_two = 2006
car_two = "Blue"

Explanation / Answer

Hi consider this sample example for your reference, Written in Ruby Script

One quick thing to note before we continue, you’ll need to surround any String-type data with " as with the vehicle.color.

Say we named the above script test_script.rb and saved it in our project root, we’d type in rails runner test_script.rb > output_script.rb. This command will run the test_script.rb file with the current rails environment loaded. If we were to do this in production, the command would probably look something like RAILS_ENV=production bundle exec rails runner test_script.rb > output_script.rb. Once our script completes, output_script.rb should contain something like the following:

After deploying and running migrations, simply run the output_script.rb just like the previous script and your data is migrated! This approach works just fine now.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote