Class: MistApi::Hours

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/hours.rb

Overview

Days/Hours of operation filter, the available days (mon, tue, wed, thu, fri, sat, sun)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(fri = SKIP, mon = SKIP, sat = SKIP, sun = SKIP, thu = SKIP, tue = SKIP, wed = SKIP) ⇒ Hours

Returns a new instance of Hours.



79
80
81
82
83
84
85
86
87
88
# File 'lib/mist_api/models/hours.rb', line 79

def initialize(fri = SKIP, mon = SKIP, sat = SKIP, sun = SKIP, thu = SKIP,
               tue = SKIP, wed = SKIP)
  @fri = fri unless fri == SKIP
  @mon = mon unless mon == SKIP
  @sat = sat unless sat == SKIP
  @sun = sun unless sun == SKIP
  @thu = thu unless thu == SKIP
  @tue = tue unless tue == SKIP
  @wed = wed unless wed == SKIP
end

Instance Attribute Details

#friString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


16
17
18
# File 'lib/mist_api/models/hours.rb', line 16

def fri
  @fri
end

#monString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


21
22
23
# File 'lib/mist_api/models/hours.rb', line 21

def mon
  @mon
end

#satString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


26
27
28
# File 'lib/mist_api/models/hours.rb', line 26

def sat
  @sat
end

#sunString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


31
32
33
# File 'lib/mist_api/models/hours.rb', line 31

def sun
  @sun
end

#thuString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


36
37
38
# File 'lib/mist_api/models/hours.rb', line 36

def thu
  @thu
end

#tueString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


41
42
43
# File 'lib/mist_api/models/hours.rb', line 41

def tue
  @tue
end

#wedString

Hour range of the day (e.g. ‘09:00-17:00`). If the hour is not defined then it’s treated as 00:00-23:59.

Returns:

  • (String)


46
47
48
# File 'lib/mist_api/models/hours.rb', line 46

def wed
  @wed
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/mist_api/models/hours.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fri = hash.key?('fri') ? hash['fri'] : SKIP
  mon = hash.key?('mon') ? hash['mon'] : SKIP
  sat = hash.key?('sat') ? hash['sat'] : SKIP
  sun = hash.key?('sun') ? hash['sun'] : SKIP
  thu = hash.key?('thu') ? hash['thu'] : SKIP
  tue = hash.key?('tue') ? hash['tue'] : SKIP
  wed = hash.key?('wed') ? hash['wed'] : SKIP

  # Create object from extracted values.
  Hours.new(fri,
            mon,
            sat,
            sun,
            thu,
            tue,
            wed)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mist_api/models/hours.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['fri'] = 'fri'
  @_hash['mon'] = 'mon'
  @_hash['sat'] = 'sat'
  @_hash['sun'] = 'sun'
  @_hash['thu'] = 'thu'
  @_hash['tue'] = 'tue'
  @_hash['wed'] = 'wed'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/mist_api/models/hours.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mist_api/models/hours.rb', line 62

def self.optionals
  %w[
    fri
    mon
    sat
    sun
    thu
    tue
    wed
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Hours | Hash)

    value against the validation is performed.



115
116
117
118
119
120
121
# File 'lib/mist_api/models/hours.rb', line 115

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



131
132
133
134
135
# File 'lib/mist_api/models/hours.rb', line 131

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} fri: #{@fri.inspect}, mon: #{@mon.inspect}, sat: #{@sat.inspect}, sun:"\
  " #{@sun.inspect}, thu: #{@thu.inspect}, tue: #{@tue.inspect}, wed: #{@wed.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



124
125
126
127
128
# File 'lib/mist_api/models/hours.rb', line 124

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} fri: #{@fri}, mon: #{@mon}, sat: #{@sat}, sun: #{@sun}, thu: #{@thu}, tue:"\
  " #{@tue}, wed: #{@wed}>"
end