Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Ruby Modules!
You have completed Ruby Modules!
Preview
In this video, we begin to implement our inventory stock counts.
Code Samples
We set up a couple of helper methods in our Inventoryable class to keep up with stock counts:
module Inventoryable
def stock_count
@stock_count ||= 0
end
def stock_count=(number)
@stock_count = number
end
def in_stock?
stock_count > 0
end
end
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
So let's go ahead and
first off we're just going to include it
0:00
in the shirt class, and
that'll be a good start.
0:05
So now, let's go ahead and
make a couple of attribute methods for
0:11
setting the stock status of an item.
0:16
So we want to be able to say,
okay this is how many
0:19
units are in stock for a shirt,
a pair of pants, an accessory, whatever.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up