Class: SeatSelector::Seat
- Inherits:
-
Object
- Object
- SeatSelector::Seat
- Defined in:
- lib/seat_selector/seat.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(args) ⇒ Seat
constructor
A new instance of Seat.
- #set_distance!(median_column) ⇒ Object
- #to_s ⇒ Object
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
#column ⇒ Object (readonly)
Returns the value of attribute column.
3 4 5 |
# File 'lib/seat_selector/seat.rb', line 3 def column @column end |
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
3 4 5 |
# File 'lib/seat_selector/seat.rb', line 3 def distance @distance end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/seat_selector/seat.rb', line 3 def id @id end |
#row ⇒ Object (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
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_s ⇒ Object
12 13 14 |
# File 'lib/seat_selector/seat.rb', line 12 def to_s @id.to_s.upcase end |