Class: SeatSelector::Seat

Inherits:
Object
  • Object
show all
Defined in:
lib/seat_selector/seat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Seat

Returns a new instance of Seat.



5
6
7
8
9
10
# File 'lib/seat_selector/seat.rb', line 5

def initialize(args)
  @row = args.fetch(:row)
  @column = args.fetch(:column)
  @id = args.fetch(:id)
  @is_available = args.fetch(:is_available, false)
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



3
4
5
# File 'lib/seat_selector/seat.rb', line 3

def column
  @column
end

#distanceObject (readonly)

Returns the value of attribute distance.



3
4
5
# File 'lib/seat_selector/seat.rb', line 3

def distance
  @distance
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/seat_selector/seat.rb', line 3

def id
  @id
end

#rowObject (readonly)

Returns the value of attribute row.



3
4
5
# File 'lib/seat_selector/seat.rb', line 3

def row
  @row
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/seat_selector/seat.rb', line 16

def available?
  @is_available
end

#set_distance!(median_column) ⇒ Object



20
21
22
# File 'lib/seat_selector/seat.rb', line 20

def set_distance!(median_column)
  @distance = (@row - 1).abs + (@column - median_column).abs
end

#to_sObject



12
13
14
# File 'lib/seat_selector/seat.rb', line 12

def to_s
  @id.to_s.upcase
end