-
-
Save manveru/4380e9fd4f17278931e0 to your computer and use it in GitHub Desktop.
This file contains 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
class Hero | |
attr_reader :items | |
def initialize(items) | |
@items = { | |
'crude sword' => 0, | |
'Armour' => 0, | |
'Helmet' => 0, | |
} | |
items.each do |item| | |
item.strip! | |
items[item] += 1 if items[item] | |
end | |
end | |
end | |
items = File.readlines("foo.txt") | |
player = Hero.new(items) | |
p player.items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment