class Celestial::World

Overview

Defines the world. A world contains many Vessel objects, and has a #timestamp (in UTC) when it was last touched.

Defined in:

parade/world.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(__temp_67 : JSON::PullParser) #

def self.new(vessels = [] of Vessel, timestamp = Time.utc_now) #

Create a new world.


[View source]

Instance Method Detail

def [](id) #

Obtain the vessel with the given ID.


[View source]
def []?(id) #

Obtain the vessel with the given ID, or nil.


[View source]
def delete(id) #

Remove a vessel from the world, shifting down all indexes after it and removing references to it.

FIXME Make a vessel's children spill into its parent when the vessel is deleted


[View source]
def http_delete(id, env) #

[View source]
def http_get(id, env) #

[View source]
def http_patch(id, env) #

[View source]
def http_post(env) #

[View source]
def index(env) #

[View source]
def on_change(&on_change : Hash(Symbol, Int32) -> ) #

Set the callback for any change to the world.

Example:

world.on_change do |message|
  puts message
end

[View source]
def timestamp : Time #

def timestamp=(_timestamp : Time) #

def to_json(json : JSON::Builder) #

def touch #

Set the timestamp to the current UTC time.


[View source]
def vessels : Array(Vessel) #

def vessels=(_vessels : Array(Vessel)) #