-
-
Save radar/797e5474e6f04711fe54de06402f4933 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 ApiRead | |
require 'open-uri' | |
require 'json' | |
attr_reader :data | |
def initialize(url) | |
# this goes fine | |
@data = JSON.parse(open(url).read)["data"] | |
end | |
# This works: | |
# a = ApiRead.new | |
# a = a.read | |
# a[0]['name'] | |
def seed | |
# This doesn't. I call this like a.seed and get "undefined method `seed' for #<Array:0x00562fb82042a0>" | |
data.each do |record| | |
puts record['id'] | |
end | |
end | |
end | |
reader = ApiRead.new | |
reader.seed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment