Class: OffTheGridTrucks::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/off_the_grid_trucks/event.rb

Direct Known Subclasses

DetailedEvent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
15
16
17
18
19
# 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

Instance Attribute Details

#assigned_vendorsObject (readonly)

Returns the value of attribute assigned_vendors.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def assigned_vendors
  @assigned_vendors
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def end_time
  @end_time
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def id
  @id
end

Returns the value of attribute is_featured.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def is_featured
  @is_featured
end

#location_idObject (readonly)

Returns the value of attribute location_id.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def location_id
  @location_id
end

#location_nameObject (readonly)

Returns the value of attribute location_name.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def location_name
  @location_name
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def name
  @name
end

#number_of_assigned_vendorsObject (readonly)

Returns the value of attribute number_of_assigned_vendors.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def number_of_assigned_vendors
  @number_of_assigned_vendors
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



6
7
8
# File 'lib/off_the_grid_trucks/event.rb', line 6

def start_time
  @start_time
end

Class Method Details

.all(from_date: 0, to_date: Time.now) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# 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