Class: ShellEv::Restrictions
- Defined in:
- lib/shell_ev/models/restrictions.rb
Overview
Restrictions Model.
Instance Attribute Summary collapse
-
#day_of_week ⇒ Array[DayOfWeekEnum]
Maximum session duration in seconds.
-
#end_date ⇒ Date
Valid until this time of the day (HH:mm).
-
#end_time ⇒ String
Valid until this time of the day (HH:mm).
-
#max_current ⇒ Float
Valid until this time of the day (HH:mm).
-
#max_duration ⇒ Integer
Maximum session duration in seconds.
-
#max_kwh ⇒ Float
Valid until this time of the day (HH:mm).
-
#max_power ⇒ Float
Valid until this time of the day (HH:mm).
-
#min_current ⇒ Float
Valid until this time of the day (HH:mm).
-
#min_duration ⇒ Integer
Minimum session duration in seconds.
-
#min_kwh ⇒ Float
Valid until this time of the day (HH:mm).
-
#min_power ⇒ Float
Valid until this time of the day (HH:mm).
-
#start_date ⇒ Date
Valid until this time of the day (HH:mm).
-
#start_time ⇒ String
Valid from this time of the day (HH:mm).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(start_time = SKIP, end_time = SKIP, start_date = SKIP, end_date = SKIP, min_kwh = SKIP, max_kwh = SKIP, min_current = SKIP, max_current = SKIP, min_power = SKIP, max_power = SKIP, min_duration = SKIP, max_duration = SKIP, day_of_week = SKIP) ⇒ Restrictions
constructor
A new instance of Restrictions.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(start_time = SKIP, end_time = SKIP, start_date = SKIP, end_date = SKIP, min_kwh = SKIP, max_kwh = SKIP, min_current = SKIP, max_current = SKIP, min_power = SKIP, max_power = SKIP, min_duration = SKIP, max_duration = SKIP, day_of_week = SKIP) ⇒ Restrictions
Returns a new instance of Restrictions.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/shell_ev/models/restrictions.rb', line 107 def initialize(start_time = SKIP, end_time = SKIP, start_date = SKIP, end_date = SKIP, min_kwh = SKIP, max_kwh = SKIP, min_current = SKIP, max_current = SKIP, min_power = SKIP, max_power = SKIP, min_duration = SKIP, max_duration = SKIP, day_of_week = SKIP) @start_time = start_time unless start_time == SKIP @end_time = end_time unless end_time == SKIP @start_date = start_date unless start_date == SKIP @end_date = end_date unless end_date == SKIP @min_kwh = min_kwh unless min_kwh == SKIP @max_kwh = max_kwh unless max_kwh == SKIP @min_current = min_current unless min_current == SKIP @max_current = max_current unless max_current == SKIP @min_power = min_power unless min_power == SKIP @max_power = max_power unless max_power == SKIP @min_duration = min_duration unless min_duration == SKIP @max_duration = max_duration unless max_duration == SKIP @day_of_week = day_of_week unless day_of_week == SKIP end |
Instance Attribute Details
#day_of_week ⇒ Array[DayOfWeekEnum]
Maximum session duration in seconds
62 63 64 |
# File 'lib/shell_ev/models/restrictions.rb', line 62 def day_of_week @day_of_week end |
#end_date ⇒ Date
Valid until this time of the day (HH:mm)
26 27 28 |
# File 'lib/shell_ev/models/restrictions.rb', line 26 def end_date @end_date end |
#end_time ⇒ String
Valid until this time of the day (HH:mm)
18 19 20 |
# File 'lib/shell_ev/models/restrictions.rb', line 18 def end_time @end_time end |
#max_current ⇒ Float
Valid until this time of the day (HH:mm)
42 43 44 |
# File 'lib/shell_ev/models/restrictions.rb', line 42 def max_current @max_current end |
#max_duration ⇒ Integer
Maximum session duration in seconds
58 59 60 |
# File 'lib/shell_ev/models/restrictions.rb', line 58 def max_duration @max_duration end |
#max_kwh ⇒ Float
Valid until this time of the day (HH:mm)
34 35 36 |
# File 'lib/shell_ev/models/restrictions.rb', line 34 def max_kwh @max_kwh end |
#max_power ⇒ Float
Valid until this time of the day (HH:mm)
50 51 52 |
# File 'lib/shell_ev/models/restrictions.rb', line 50 def max_power @max_power end |
#min_current ⇒ Float
Valid until this time of the day (HH:mm)
38 39 40 |
# File 'lib/shell_ev/models/restrictions.rb', line 38 def min_current @min_current end |
#min_duration ⇒ Integer
Minimum session duration in seconds
54 55 56 |
# File 'lib/shell_ev/models/restrictions.rb', line 54 def min_duration @min_duration end |
#min_kwh ⇒ Float
Valid until this time of the day (HH:mm)
30 31 32 |
# File 'lib/shell_ev/models/restrictions.rb', line 30 def min_kwh @min_kwh end |
#min_power ⇒ Float
Valid until this time of the day (HH:mm)
46 47 48 |
# File 'lib/shell_ev/models/restrictions.rb', line 46 def min_power @min_power end |
#start_date ⇒ Date
Valid until this time of the day (HH:mm)
22 23 24 |
# File 'lib/shell_ev/models/restrictions.rb', line 22 def start_date @start_date end |
#start_time ⇒ String
Valid from this time of the day (HH:mm)
14 15 16 |
# File 'lib/shell_ev/models/restrictions.rb', line 14 def start_time @start_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/shell_ev/models/restrictions.rb', line 128 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. start_time = hash.key?('startTime') ? hash['startTime'] : SKIP end_time = hash.key?('endTime') ? hash['endTime'] : SKIP start_date = hash.key?('startDate') ? hash['startDate'] : SKIP end_date = hash.key?('endDate') ? hash['endDate'] : SKIP min_kwh = hash.key?('minKwh') ? hash['minKwh'] : SKIP max_kwh = hash.key?('maxKwh') ? hash['maxKwh'] : SKIP min_current = hash.key?('minCurrent') ? hash['minCurrent'] : SKIP max_current = hash.key?('maxCurrent') ? hash['maxCurrent'] : SKIP min_power = hash.key?('minPower') ? hash['minPower'] : SKIP max_power = hash.key?('maxPower') ? hash['maxPower'] : SKIP min_duration = hash.key?('minDuration') ? hash['minDuration'] : SKIP max_duration = hash.key?('maxDuration') ? hash['maxDuration'] : SKIP day_of_week = hash.key?('dayOfWeek') ? hash['dayOfWeek'] : SKIP # Create object from extracted values. Restrictions.new(start_time, end_time, start_date, end_date, min_kwh, max_kwh, min_current, max_current, min_power, max_power, min_duration, max_duration, day_of_week) end |
.names ⇒ Object
A mapping from model property names to API property names.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/shell_ev/models/restrictions.rb', line 65 def self.names @_hash = {} if @_hash.nil? @_hash['start_time'] = 'startTime' @_hash['end_time'] = 'endTime' @_hash['start_date'] = 'startDate' @_hash['end_date'] = 'endDate' @_hash['min_kwh'] = 'minKwh' @_hash['max_kwh'] = 'maxKwh' @_hash['min_current'] = 'minCurrent' @_hash['max_current'] = 'maxCurrent' @_hash['min_power'] = 'minPower' @_hash['max_power'] = 'maxPower' @_hash['min_duration'] = 'minDuration' @_hash['max_duration'] = 'maxDuration' @_hash['day_of_week'] = 'dayOfWeek' @_hash end |
.nullables ⇒ Object
An array for nullable fields
103 104 105 |
# File 'lib/shell_ev/models/restrictions.rb', line 103 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/shell_ev/models/restrictions.rb', line 84 def self.optionals %w[ start_time end_time start_date end_date min_kwh max_kwh min_current max_current min_power max_power min_duration max_duration day_of_week ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
173 174 175 176 177 178 179 180 181 |
# File 'lib/shell_ev/models/restrictions.rb', line 173 def inspect class_name = self.class.name.split('::').last "<#{class_name} start_time: #{@start_time.inspect}, end_time: #{@end_time.inspect},"\ " start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect}, min_kwh:"\ " #{@min_kwh.inspect}, max_kwh: #{@max_kwh.inspect}, min_current: #{@min_current.inspect},"\ " max_current: #{@max_current.inspect}, min_power: #{@min_power.inspect}, max_power:"\ " #{@max_power.inspect}, min_duration: #{@min_duration.inspect}, max_duration:"\ " #{@max_duration.inspect}, day_of_week: #{@day_of_week.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
163 164 165 166 167 168 169 170 |
# File 'lib/shell_ev/models/restrictions.rb', line 163 def to_s class_name = self.class.name.split('::').last "<#{class_name} start_time: #{@start_time}, end_time: #{@end_time}, start_date:"\ " #{@start_date}, end_date: #{@end_date}, min_kwh: #{@min_kwh}, max_kwh: #{@max_kwh},"\ " min_current: #{@min_current}, max_current: #{@max_current}, min_power: #{@min_power},"\ " max_power: #{@max_power}, min_duration: #{@min_duration}, max_duration: #{@max_duration},"\ " day_of_week: #{@day_of_week}>" end |