Fixed news parser a little to not fail if it gets an empty json hash

This commit is contained in:
2025-04-26 07:51:13 -05:00
parent 1401b80057
commit e4a0d2a848

View File

@@ -6,7 +6,7 @@ class W3DHub
def initialize(response)
@data = JSON.parse(response, symbolize_names: true)
@items = @data[:news].map { |item| Item.new(item) }
@items = (@data[:news] && @data[:news].is_a?(Array)) ? @data[:news].map { |item| Item.new(item) } : []
end
class Item