- using class level state is generally considered to be dangerous. (@@var type stuff) - OK for this project since it's the only thing using its own code, but if this were a gem where people could pull in your code, imagine what would happen if someone accesses the Conditions/Equipments/Spells
@@all
attribute and changes stuff?
- as an alternative, you could create wrapping objects (something like
EquipmentCollection
) that exist just to fetch and hold all of the items, and your CLI would talk to those Collection objects to present the lists of all of the items.
- consider using a gemfile/gemspec (gemspec if this could be a gem) to declare your dependencies
- declaring an array and shoveling items into it is redundant in ruby:
things = [] doodads.each { |dd| things << "based god say: #{dd}" } # is equivalent to: things = doodads.map { |dd| "based god says: #{dd}" }
- Mapping + hash access can simplify some code:
equipment_names = [] equipment_array.each do |hash| hash.collect do |key, value| if key == "name" equipment_names << value end end end equipment_names # is equivalent to: equipment_names = equipment_array.map do |hash| hash['name'] end