Class: Gonebusy::EntitiesSlots

Inherits:
BaseModel show all
Defined in:
lib/gonebusy/models/entities_slots.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(date = nil, slots = nil) ⇒ EntitiesSlots

Returns a new instance of EntitiesSlots.



24
25
26
27
28
# File 'lib/gonebusy/models/entities_slots.rb', line 24

def initialize(date = nil,
               slots = nil)
  @date = date
  @slots = slots
end

Instance Attribute Details

#dateDateTime

date of availability

Returns:

  • (DateTime)


8
9
10
# File 'lib/gonebusy/models/entities_slots.rb', line 8

def date
  @date
end

#slotsList of String

array of available time slots

Returns:



12
13
14
# File 'lib/gonebusy/models/entities_slots.rb', line 12

def slots
  @slots
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gonebusy/models/entities_slots.rb', line 31

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    date = DateTime.iso8601(hash["date"]) if hash["date"]
    slots = hash["slots"]

    # Create object from extracted values
    EntitiesSlots.new(date,
                      slots)
  end
end

.namesObject

A mapping from model property names to API property names



15
16
17
18
19
20
21
22
# File 'lib/gonebusy/models/entities_slots.rb', line 15

def self.names
  if @hash.nil?
    @hash = {}
    @hash["date"] = "date"
    @hash["slots"] = "slots"
  end
  @hash
end