Skip to content
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

Natasha Vasquez #8

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

nvnatasha
Copy link

No description provided.


def initialize(item_details)
@name = item_details[:name]
@price = item_details[:price]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interaction pattern asks the price string to be cleaned (remove the $) and converted to a float.

@@ -1,3 +1,10 @@
class Item

attr_reader :name, :price

def initialize(item_details)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just item is probably a nice param name here.



attr_reader :name, :vendors
attr_accessor :sorted_item_list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this variable need to be updated outside of this class? Probably not.

def total_inventory
inventory = {}
vendors.each do |vendor|
vendor.inventory.each do |item, quantity|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice logic in here!

def overstocked_items
overstocked = []
total_inventory.each do |item, data|
if data[:vendors].length > 1 && data[:quantity] > 50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great conditional logic!

@inventory.each do |item, quantity|
item_price = item.price.delete('$').to_f
total_revenue += item_price * quantity
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here! Really great work with this encapsulated class, though.

end

it 'exists' do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace! And pay attention to indentation :)

end

it 'can return vendor names, items sold at vendors, and vendor revenue' do
@vendor1 = Vendor.new("Rocky Mountain Fresh")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of this setup could have been included in your beforeach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants