mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Games page back to semi-functional; games are out of order however
This commit is contained in:
32
lib/api/news.rb
Normal file
32
lib/api/news.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class W3DHub
|
||||
class Api
|
||||
class News
|
||||
attr_reader :items
|
||||
|
||||
def initialize(response)
|
||||
@data = JSON.parse(response, symbolize_names: true)
|
||||
|
||||
@items = @data[:news].map { |item| Item.new(item) }
|
||||
end
|
||||
|
||||
class Item
|
||||
attr_reader :topic_id, :title, :blurb, :image, :uri, :author, :author_uri, :timestamp, :date, :time
|
||||
|
||||
def initialize(hash)
|
||||
@data = hash
|
||||
|
||||
@topic_id = Integer(@data[:"topic-id"])
|
||||
@title = @data[:title]
|
||||
@blurb = @data[:blurb]
|
||||
@image = @data[:image].strip
|
||||
@uri = @data[:uri].strip
|
||||
@author = @data[:author]
|
||||
@author_uri = @data[:"author-uri"].strip
|
||||
@timestamp = Time.at(Integer(@data[:timestamp]))
|
||||
@date = @data[:date]
|
||||
@time = @data[:time]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user