Class: Hermitcraft::API

Inherits:
Object
  • Object
show all
Defined in:
lib/hermitcraft/api.rb

Overview

This class handles interaction with Hermitcraft.com’s API, which is an open endpoint located at hermitcraft.com/api/videos. Hypno uses it in the site’s Angular app to display videos on the main site.

Constant Summary collapse

ENDPOINT =
'http://hermitcraft.com/api/videos'

Class Method Summary collapse

Class Method Details

.videos(time = nil) ⇒ Array

Fetches 25 videos in reverse chronological order from a point in time.

Returns:

  • (Array)

    a bunch of Hermitcraft::Video objects.



17
18
19
20
21
22
23
24
# File 'lib/hermitcraft/api.rb', line 17

def self.videos(time = nil)
  time ||= Time.now.utc
  time = time.iso8601
  params = {type: 'All', start: time}

  response = request(params)
  process_response(response)
end