-
Notifications
You must be signed in to change notification settings - Fork 22
Done(Panda, Tiger, Eagle) #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
var114
wants to merge
11
commits into
RubyoffRails:master
Choose a base branch
from
var114:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
db6b21b
PTE
var114 aa2d68c
Create vehicle.rb
var114 67f656c
Create auto.rb
var114 dcf8498
Create motor.rb
var114 62542eb
Create vehicle_spec.rb
var114 d896431
Create auto_spec.rb
var114 2f39034
Create motor_spec
var114 6defed1
Create spec_helper
var114 0eb8b70
Update vehicle_spec.rb
var114 3c2923f
Update motor.rb
var114 c7013c7
Update auto.rb
var114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| require_relative "Vehicle" | ||
|
|
||
| class Auto < Vehicle | ||
|
|
||
| def self.wheels | ||
| @@wheels = 4 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| require_relative "Vehicle" | ||
|
|
||
| class Motor < Vehicle | ||
|
|
||
| def self.wheels | ||
| @@wheels = 2 | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| class Vehicle | ||
|
|
||
| @@vehicle = [] #can be used anywhere. | ||
|
|
||
| attr_reader :color, :make, :model, :year, :model | ||
| def initialize(hash={}) | ||
| @@vehicle << self | ||
| @color = hash.fetch(:color) | ||
| @make = hash.fetch(:make) | ||
| @model = hash.fetch(:model) | ||
| @year = hash.fetch(:year) | ||
| end | ||
|
|
||
| def self.wheels | ||
| @wheels = nil | ||
| end | ||
|
|
||
| def self.vehicles | ||
| @@vehicle | ||
| end | ||
|
|
||
| def self.favorite_car | ||
| @@vehicle.select { |i| i.color == 'Blue' && i.model == 'Accord'} #select returns the ary that's true to the conditon | ||
| end | ||
|
|
||
| def to_s | ||
| "#{color}, #{make}, #{model}, #{year}" | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
|
|
||
| require_relative "spec_helper" | ||
|
|
||
| describe Auto do | ||
| it "should have four wheels" do | ||
| Auto.wheels.should eq(4) | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
|
|
||
| require_relative "spec_helper" | ||
|
|
||
| describe Motor do | ||
| it "should have four wheels" do | ||
| Motor.wheels.should eq(2) | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| require "rspec" | ||
| require 'bundler/setup' | ||
| require_relative '../db/setup' | ||
| require_relative "../models/vehicle" | ||
| require_relative "../models/auto" | ||
| require_relative "../models/motor" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| require_relative "spec_helper" | ||
|
|
||
| describe Vehicle do | ||
|
|
||
| it "should start with no wheels" do | ||
| Vehicle.wheels.should be_nil | ||
| end | ||
|
|
||
| it "should take input to describe the automobile" do | ||
| auto = Vehicle.new(color: "black", make: "Honda", model: "Accord", year: "2007") | ||
| auto.color.should eq("black") | ||
| auto.make.should eq("Honda") | ||
| auto.model.should eq("Accord") | ||
| auto.year.should eq("2007") | ||
| end | ||
|
|
||
| it "should be able to filter the vehicles to only blue honda accords" do | ||
| auto1 = Vehicle.new(color: "Blue", make: "Honda", model: "Accord", year: "2007") | ||
| auto2 = Vehicle.new(color: "Blue", make: "Honda", model: "Accord", year: "2009") | ||
| auto3 = Vehicle.new(color: "Orange", make: "Yamaha", model: "Z7.0", year: "2019") | ||
| results = Vehicle.favorite_car | ||
| results.count.should eq(2) | ||
| end | ||
| ends |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're calling a method in Ruby, you don't need to assign it to a variable. so here you could: