Sha256: cc4a220200ca1ecc91646edf24de0d863df442ba14033552d3a34a8859621c0e

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

class AcnhVillager::API

    def self.scrape_villagers
        resp = RestClient.get('http://acnhapi.com/v1/villagers/')
        villager_hash = JSON.parse(resp.body, symbolize_names:true) 
        villager_hash.each do | k, v | 
            AcnhVillager::Villager.new(villager_hash[k]) 
        end
    end

    def self.scrape_villager_details(villager)
        resp = RestClient.get(villager.url)
        villager_hash = JSON.parse(resp.body, symbolize_names:true) 
        villager.jp_name = villager_hash[:name][:"name-JPja"]
        villager.personality = villager_hash[:personality]
        villager.birthday = villager_hash[:'birthday-string']
        villager.species = villager_hash[:species]
        villager.gender = villager_hash[:gender]
        villager.hobby = villager_hash[:hobby]
        villager.catch_phrase = villager_hash[:"catch-phrase"]
        villager.image_url = villager_hash[:image_uri]
        villager.saying = villager_hash[:saying]
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acnh_villager-0.1.1 lib/acnh_villager/api.rb