class OffTheGridTrucks::Event

Attributes

assigned_vendors[R]
end_time[R]
id[R]
location_id[R]
location_name[R]
name[R]
number_of_assigned_vendors[R]
start_time[R]

Public Class Methods

all(from_date: 0, to_date: Time.now) click to toggle source
# File lib/off_the_grid_trucks/event.rb, line 22
def all(from_date: 0, to_date: Time.now)
  query = {
    dateFrom: date_to_seconds(from_date),
    dateTo: date_to_seconds(to_date)
  }
  Request.get(
    resource: 'events',
    query: query
  )['events'].map { |event| new(event) }
end
new(args) click to toggle source
# File lib/off_the_grid_trucks/event.rb, line 9
def initialize(args)
  @id = args.fetch('id') {}
  @name = args.fetch('name') {}
  @start_time = args.fetch('startTime') {}
  @end_time = args.fetch('endTime') {}
  @location_id = args.fetch('locationId') {}
  @location_name = args.fetch('locationName') {}
  @assigned_vendors = args.fetch('assignedVendors') {}
  @number_of_assigned_vendors = args.fetch('numberOfAssignedVendors') {}
  @is_featured = args.fetch('isFeatured') {}
end

Private Class Methods

date_to_seconds(date) click to toggle source
# File lib/off_the_grid_trucks/event.rb, line 35
def date_to_seconds(date)
  date.to_i.to_s.ljust(13, '0').to_i
end