Games page back to semi-functional; games are out of order however

This commit is contained in:
2021-11-14 13:23:57 -06:00
parent b2a2a961b3
commit 077f74cd2b
9 changed files with 145 additions and 66 deletions

32
lib/api/news.rb Normal file
View 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