Class: Twilic::Core::Session::SessionState
- Inherits:
-
Data
- Object
- Data
- Twilic::Core::Session::SessionState
- Defined in:
- lib/twilic/core/session.rb
Instance Attribute Summary collapse
-
#base_snapshots ⇒ Object
readonly
Returns the value of attribute base_snapshots.
-
#dictionaries ⇒ Object
readonly
Returns the value of attribute dictionaries.
-
#dictionary_profiles ⇒ Object
readonly
Returns the value of attribute dictionary_profiles.
-
#encode_shape_observations ⇒ Object
readonly
Returns the value of attribute encode_shape_observations.
-
#field_enums ⇒ Object
readonly
Returns the value of attribute field_enums.
-
#key_table ⇒ Object
readonly
Returns the value of attribute key_table.
-
#last_schema_id ⇒ Object
readonly
Returns the value of attribute last_schema_id.
-
#next_base_id ⇒ Object
readonly
Returns the value of attribute next_base_id.
-
#next_dictionary_id ⇒ Object
readonly
Returns the value of attribute next_dictionary_id.
-
#next_template_id ⇒ Object
readonly
Returns the value of attribute next_template_id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#previous_message ⇒ Object
readonly
Returns the value of attribute previous_message.
-
#previous_message_size ⇒ Object
readonly
Returns the value of attribute previous_message_size.
-
#schemas ⇒ Object
readonly
Returns the value of attribute schemas.
-
#shape_table ⇒ Object
readonly
Returns the value of attribute shape_table.
-
#string_table ⇒ Object
readonly
Returns the value of attribute string_table.
-
#template_columns ⇒ Object
readonly
Returns the value of attribute template_columns.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Class Method Summary collapse
Instance Method Summary collapse
- #allocate_base_id ⇒ Object
- #allocate_dictionary_id ⇒ Object
- #allocate_template_id ⇒ Object
- #get_base_snapshot(base_id) ⇒ Object
- #register_base_snapshot(base_id, message) ⇒ Object
- #reset_state ⇒ Object
- #reset_tables ⇒ Object
Instance Attribute Details
#base_snapshots ⇒ Object (readonly)
Returns the value of attribute base_snapshots
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def base_snapshots @base_snapshots end |
#dictionaries ⇒ Object (readonly)
Returns the value of attribute dictionaries
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def dictionaries @dictionaries end |
#dictionary_profiles ⇒ Object (readonly)
Returns the value of attribute dictionary_profiles
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def dictionary_profiles @dictionary_profiles end |
#encode_shape_observations ⇒ Object (readonly)
Returns the value of attribute encode_shape_observations
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def encode_shape_observations @encode_shape_observations end |
#field_enums ⇒ Object (readonly)
Returns the value of attribute field_enums
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def field_enums @field_enums end |
#key_table ⇒ Object (readonly)
Returns the value of attribute key_table
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def key_table @key_table end |
#last_schema_id ⇒ Object (readonly)
Returns the value of attribute last_schema_id
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def last_schema_id @last_schema_id end |
#next_base_id ⇒ Object (readonly)
Returns the value of attribute next_base_id
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def next_base_id @next_base_id end |
#next_dictionary_id ⇒ Object (readonly)
Returns the value of attribute next_dictionary_id
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def next_dictionary_id @next_dictionary_id end |
#next_template_id ⇒ Object (readonly)
Returns the value of attribute next_template_id
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def next_template_id @next_template_id end |
#options ⇒ Object (readonly)
Returns the value of attribute options
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def @options end |
#previous_message ⇒ Object (readonly)
Returns the value of attribute previous_message
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def @previous_message end |
#previous_message_size ⇒ Object (readonly)
Returns the value of attribute previous_message_size
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def @previous_message_size end |
#schemas ⇒ Object (readonly)
Returns the value of attribute schemas
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def schemas @schemas end |
#shape_table ⇒ Object (readonly)
Returns the value of attribute shape_table
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def shape_table @shape_table end |
#string_table ⇒ Object (readonly)
Returns the value of attribute string_table
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def string_table @string_table end |
#template_columns ⇒ Object (readonly)
Returns the value of attribute template_columns
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def template_columns @template_columns end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates
136 137 138 |
# File 'lib/twilic/core/session.rb', line 136 def templates @templates end |
Class Method Details
.new_state ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/twilic/core/session.rb', line 142 def self.new_state new( options: SessionOptions.default, key_table: InternTable.new_table, string_table: InternTable.new_table, shape_table: ShapeTable.new_table, encode_shape_observations: {}, base_snapshots: [], templates: {}, template_columns: {}, field_enums: {}, dictionaries: {}, dictionary_profiles: {}, schemas: {}, last_schema_id: nil, previous_message: nil, previous_message_size: nil, next_base_id: 0, next_template_id: 0, next_dictionary_id: 0 ) end |
.with_options(options) ⇒ Object
165 166 167 |
# File 'lib/twilic/core/session.rb', line 165 def self.() new_state.with(options: ) end |
Instance Method Details
#allocate_base_id ⇒ Object
178 179 180 181 |
# File 'lib/twilic/core/session.rb', line 178 def allocate_base_id id = next_base_id with(next_base_id: next_base_id + 1).next_base_id == id ? id : id end |
#allocate_dictionary_id ⇒ Object
189 190 191 192 193 |
# File 'lib/twilic/core/session.rb', line 189 def allocate_dictionary_id id = next_dictionary_id with(next_dictionary_id: next_dictionary_id + 1) id end |
#allocate_template_id ⇒ Object
183 184 185 186 187 |
# File 'lib/twilic/core/session.rb', line 183 def allocate_template_id id = next_template_id with(next_template_id: next_template_id + 1) id end |
#get_base_snapshot(base_id) ⇒ Object
195 196 197 198 199 200 |
# File 'lib/twilic/core/session.rb', line 195 def get_base_snapshot(base_id) entry = base_snapshots.find { |e| e.id == base_id } return [nil, false] unless entry [entry.., true] end |
#register_base_snapshot(base_id, message) ⇒ Object
169 170 171 172 173 174 175 176 |
# File 'lib/twilic/core/session.rb', line 169 def register_base_snapshot(base_id, ) filtered = base_snapshots.reject { |e| e.id == base_id } filtered << BaseSnapshotEntry.new(id: base_id, message: .) while filtered.length > .max_base_snapshots filtered.shift end with(base_snapshots: filtered) end |
#reset_state ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/twilic/core/session.rb', line 212 def reset_state reset_tables.with( base_snapshots: [], templates: {}, template_columns: {}, dictionaries: {}, dictionary_profiles: {}, schemas: {}, last_schema_id: nil, previous_message: nil, previous_message_size: nil, next_base_id: 0, next_template_id: 0, next_dictionary_id: 0 ) end |
#reset_tables ⇒ Object
202 203 204 205 206 207 208 209 210 |
# File 'lib/twilic/core/session.rb', line 202 def reset_tables with( key_table: InternTable.new_table, string_table: InternTable.new_table, shape_table: ShapeTable.new_table, encode_shape_observations: {}, field_enums: {} ) end |