Class: DublinBikes::StationStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/dublin_bikes/station_status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(station) ⇒ StationStatus

Returns a new instance of StationStatus.



5
6
7
8
9
10
11
12
# File 'lib/dublin_bikes/station_status.rb', line 5

def initialize(station)
  @available_bikes = station.available
  @free_spaces = station.free
  @total_capacity = station.total
  @open = station.open == 1 ? true : false
  @accepts_credit_card = station.ticket == 1 ? true : false
  @updated_at = Time.at(station.updated)
end

Instance Attribute Details

#available_bikesObject (readonly)

Returns the value of attribute available_bikes.



3
4
5
# File 'lib/dublin_bikes/station_status.rb', line 3

def available_bikes
  @available_bikes
end

#free_spacesObject (readonly)

Returns the value of attribute free_spaces.



3
4
5
# File 'lib/dublin_bikes/station_status.rb', line 3

def free_spaces
  @free_spaces
end

#total_capacityObject (readonly)

Returns the value of attribute total_capacity.



3
4
5
# File 'lib/dublin_bikes/station_status.rb', line 3

def total_capacity
  @total_capacity
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



3
4
5
# File 'lib/dublin_bikes/station_status.rb', line 3

def updated_at
  @updated_at
end

Instance Method Details

#accepts_credit_card?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dublin_bikes/station_status.rb', line 22

def accepts_credit_card?
  @accepts_credit_card
end

#closed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dublin_bikes/station_status.rb', line 18

def closed?
  !open?
end

#open?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dublin_bikes/station_status.rb', line 14

def open?
  @open
end