Sha256: fb7a66fa3a2f88072ca1be808b817d05b8fa5d9e4fe5d37fe790ba88755d499f
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
class Bnet::Diablo3::Follower < Bnet::BnetResource attr_accessor :follower_type, :level, :raw_attributes, :magic_find, :gold_find, :experience_bonus, #associations :items, :skills def self.from_api(follower_type, raw_response) follower = new(follower_type: follower_type) follower.raw_attributes = raw_response follower.level = raw_response["level"] assign_items_from_raw_items(follower, raw_response["items"]) if raw_response["items"] assign_skills_from_raw_skills(follower, raw_response["skills"]) if raw_response["skills"] follower.magic_find = raw_response["stats"]["magicFind"] follower.gold_find = raw_response["stats"]["goldFind"] follower.experience_bonus = raw_response["stats"]["experienceBonus"] return follower end private def self.assign_items_from_raw_items(follower, raw_items) follower.items = raw_items.collect do |location, item_props| Bnet::Diablo3::Item.from_api(location, item_props) end return follower end def self.assign_skills_from_raw_skills(follower, raw_skills) follower.skills = raw_skills.collect do |raw_skill| Bnet::Diablo3::Skill.from_api(raw_skill) unless raw_skill.empty? end follower.skills = follower.skills.compact return follower end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bnet-0.0.10 | lib/bnet/diablo3/follower.rb |
bnet-0.0.5 | lib/bnet/diablo3/follower.rb |
bnet-0.0.4 | lib/bnet/diablo3/follower.rb |