mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 17:22:35 +00:00
Fixed news parser a little to not fail if it gets an empty json hash
This commit is contained in:
@@ -6,7 +6,7 @@ class W3DHub
|
|||||||
def initialize(response)
|
def initialize(response)
|
||||||
@data = JSON.parse(response, symbolize_names: true)
|
@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
|
end
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
|
|||||||
Reference in New Issue
Block a user