Class: GymFinder::Client::Slot

Inherits:
Object
  • Object
show all
Defined in:
lib/gym_finder/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gym:, court:, date:, time_slot:, client:) ⇒ Slot

Returns a new instance of Slot.



51
52
53
54
55
56
57
# File 'lib/gym_finder/client.rb', line 51

def initialize(gym:, court:, date:, time_slot:, client:)
  @gym = gym
  @court = court
  @date = date
  @time_slot = time_slot
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



50
51
52
# File 'lib/gym_finder/client.rb', line 50

def client
  @client
end

#courtObject

Returns the value of attribute court.



50
51
52
# File 'lib/gym_finder/client.rb', line 50

def court
  @court
end

#dateObject

Returns the value of attribute date.



50
51
52
# File 'lib/gym_finder/client.rb', line 50

def date
  @date
end

#gymObject

Returns the value of attribute gym.



50
51
52
# File 'lib/gym_finder/client.rb', line 50

def gym
  @gym
end

#time_slotObject

Returns the value of attribute time_slot.



50
51
52
# File 'lib/gym_finder/client.rb', line 50

def time_slot
  @time_slot
end

Instance Method Details

#to_json(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/gym_finder/client.rb', line 59

def to_json(*args)
  {
    gym: @gym.name,
    type: @court.name,
    court: @time_slot.court,
    price: @time_slot.price,
    status: @time_slot.status,
    time: Time.new(@date.year, @date.month, @date.day, @time_slot.time).iso8601,
    gym_homepage: @gym.homepage,
    reservation_link: "https://#{@client.req.host}#{@client.req.path}?module=net_booking&files=booking_place&StepFlag=25&QPid=#{@time_slot.qpid}&QTime=#{@time_slot.time}&PT=#{@court.pt}&D=#{@date.strftime('%Y/%m/%d')}"
  }.to_json(*args)
end