Skip to content

Instantly share code, notes, and snippets.

@apeiros
Last active December 14, 2015 23:19
Show Gist options
  • Save apeiros/cb0fab5c4d7ffd9309da to your computer and use it in GitHub Desktop.
Save apeiros/cb0fab5c4d7ffd9309da to your computer and use it in GitHub Desktop.
class EnemyClass
attr_reader :name
def initialize(id, name, attack, defense, hp)
@id = id
@name = name
@attack = attack
@defense = defense
@hp = hp
end
end
module EnemyModule
def self.getEnemies
enemy_array = [] # variable declerations need to be within the method
allEnemies = []
enemies = open(ENEMY_URL)
enemies.each_line {|line| enemy_array.push(line)}
# create allEnemy array of EnemyClass objects
enemy_array.each {|en| allEnemies << EnemyClass.new(*en.split("/")) }
allEnemies.each { |x| puts x }
return allEnemies
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment