Class: SpreeCmCommissioner::Integrations::Larryta::Resources::SeatAvailability
- Inherits:
-
Base
- Object
- Base
- SpreeCmCommissioner::Integrations::Larryta::Resources::SeatAvailability
- Defined in:
- app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb
Overview
Represents seat availability response from Larryta API
Instance Attribute Summary collapse
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#seat_numbers ⇒ Object
Returns the value of attribute seat_numbers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#total_seats ⇒ Object
Returns the value of attribute total_seats.
Instance Method Summary collapse
-
#available? ⇒ Boolean
Returns true if seats are available.
-
#count ⇒ Object
Returns the count of available seats.
-
#fully_booked? ⇒ Boolean
Returns true if no seats are available.
-
#initialize(data) ⇒ SeatAvailability
constructor
rubocop:disable Lint/MissingSuper.
-
#seat_list ⇒ Object
Returns array of seat numbers.
-
#to_h ⇒ Object
Returns a hash representation.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ SeatAvailability
rubocop:disable Lint/MissingSuper
7 8 9 10 11 12 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 7 def initialize(data) # rubocop:disable Lint/MissingSuper @total_seats = data['total_seat'] @seat_numbers = data['seat_nums'] @status = data['status'] @msg = data['msg'] end |
Instance Attribute Details
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
5 6 7 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 5 def msg @msg end |
#seat_numbers ⇒ Object
Returns the value of attribute seat_numbers.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 4 def seat_numbers @seat_numbers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 5 def status @status end |
#total_seats ⇒ Object
Returns the value of attribute total_seats.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 4 def total_seats @total_seats end |
Instance Method Details
#available? ⇒ Boolean
Returns true if seats are available
22 23 24 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 22 def available? status == true && total_seats.to_i.positive? end |
#count ⇒ Object
Returns the count of available seats
32 33 34 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 32 def count total_seats end |
#fully_booked? ⇒ Boolean
Returns true if no seats are available
27 28 29 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 27 def fully_booked? total_seats.to_i.zero? end |
#seat_list ⇒ Object
Returns array of seat numbers
15 16 17 18 19 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 15 def seat_list return [] if seat_numbers.blank? seat_numbers.split(',').map(&:to_i).sort end |
#to_h ⇒ Object
Returns a hash representation
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb', line 37 def to_h { total_seats: total_seats, seat_numbers: seat_list, count: count, available: available?, fully_booked: fully_booked?, status: status, message: msg } end |