Class: TocDoc::Availability

Inherits:
Resource show all
Defined in:
lib/toc_doc/models/availability.rb

Overview

Represents a single availability date entry returned by the Doctolib API.

Examples:

avail = TocDoc::Availability.new('date' => '2026-02-28', 'slots' => ['2026-02-28T10:00:00.000+01:00'])
avail.date       #=> #<Date: 2026-02-28>
avail.raw_date   #=> "2026-02-28"
avail.slots      #=> [#<DateTime: 2026-02-28T10:00:00.000+01:00>]
avail.raw_slots  #=> ["2026-02-28T10:00:00.000+01:00"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, #method_missing, #to_h

Constructor Details

#initialize(*attrs) ⇒ Availability

Returns a new instance of Availability.

Parameters:

  • attrs (Hash)

    raw attributes from the API response, expected to include



18
19
20
21
22
23
24
# File 'lib/toc_doc/models/availability.rb', line 18

def initialize(*attrs)
  super
  raw = build_raw(@attrs)

  @date = Date.parse(raw['date']) if raw['date']
  @slots = raw['slots'].map { |s| DateTime.parse(s) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TocDoc::Resource

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



15
16
17
# File 'lib/toc_doc/models/availability.rb', line 15

def date
  @date
end

#slotsObject (readonly)

Returns the value of attribute slots.



15
16
17
# File 'lib/toc_doc/models/availability.rb', line 15

def slots
  @slots
end