Skip to content

Commit

Permalink
Initial conversion from java
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Sedano committed Mar 22, 2011
1 parent 1fd1d99 commit 205d4d7
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/*
66 changes: 66 additions & 0 deletions gilded_rose.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
class GildedRose

@items = {}

def initialize
items << Item("+5 Dexterity Vest", 10, 20)
items << Item("Aged Brie", 2, 0)
items << Item("Elixir of the Mongoose", 5, 7)
items << Item("Sulfuras, Hand of Ragnaros", 0, 80)
items << Item("Backstage passes to a TAFKAL80ETC concert", 15, 20)
items << Item("Conjured Mana Cake", 3, 6)
end

self.def updateQuality do

@items.each do |item|
if ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
if (item.getQuality() > 0)
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
item.setQuality(item.getQuality() - 1);
end
end
else
if (item.getQuality() < 50)
item.setQuality(item.getQuality() + 1);

if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
if (item.getSellIn() < 11)
if (item.getQuality() < 50)
item.setQuality(item.getQuality() + 1);
end
end

if (item.getSellIn() < 6)
if (item.getQuality() < 50)
item.setQuality(item.getQuality() + 1);
end
end
end
end
end

if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
item.setSellIn(item.getSellIn() - 1);
end

if (item.getSellIn() < 0)
if (!"Aged Brie".equals(item.getName()))
if (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName()))
if (item.getQuality() > 0)
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName()))
item.setQuality(item.getQuality() - 1);
end
end
else
item.setQuality(item.getQuality() - item.getQuality());
end
else
if (item.getQuality() < 50)
item.setQuality(item.getQuality() + 1);
end
end
end
end
end
end
10 changes: 10 additions & 0 deletions gilded_rose_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'spec_helper'

describe GildedRose do

it "should do something" do

end


end
13 changes: 13 additions & 0 deletions item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Item

attr_accessor :name, :sellin, :quality


def initialize (name, sellIn, quality)
@name = name
@sellIn = sellIn
@quality = quality
end


end

0 comments on commit 205d4d7

Please sign in to comment.