Class: SpreeCmCommissioner::Integrations::Larryta::Resources::Seat

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_api_response, #to_h

Constructor Details

#initialize(data) ⇒ Seat

rubocop:disable Lint/MissingSuper



5
6
7
8
9
10
11
12
13
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 5

def initialize(data) # rubocop:disable Lint/MissingSuper
  @label = data['label'].to_s
  @external_class = data['class']
  @check_value = data['check_value']
  @booking = data['booking'] || []
  @loading = data['loading']
  @row = data['row']
  @column = data['column']
end

Instance Attribute Details

#bookingObject

Returns the value of attribute booking.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def booking
  @booking
end

#check_valueObject

Returns the value of attribute check_value.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def check_value
  @check_value
end

#columnObject

Returns the value of attribute column.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def column
  @column
end

#external_classObject

Returns the value of attribute external_class.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def external_class
  @external_class
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def label
  @label
end

#loadingObject

Returns the value of attribute loading.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def loading
  @loading
end

#rowObject

Returns the value of attribute row.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 3

def row
  @row
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 23

def available?
  external_class == 'available' && booking.empty?
end

#block_typeObject



15
16
17
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 15

def block_type
  driver? ? :driver : :seat
end

#booked?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 27

def booked?
  !available?
end

#driver?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb', line 19

def driver?
  label.match?(/DR/i)
end