Module: Reddit::JsonListing::InstanceMethods

Defined in:
lib/ruby_reddit_api/json_listing.rb

Instance Method Summary collapse

Instance Method Details

#parse(json) ⇒ true

Iterate over JSON and set instance variables that map to each JSON key

Parameters:

  • JSON (Hash)

    received from Reddit

Returns:

  • (true)


38
39
40
41
42
43
# File 'lib/ruby_reddit_api/json_listing.rb', line 38

def parse(json)
  json.keys.each do |key|
    instance_variable_set("@#{key}", json[key])
  end
  true
end