Class: Twilic::Core::Session::MutableInternTable
- Inherits:
-
Object
- Object
- Twilic::Core::Session::MutableInternTable
- Defined in:
- lib/twilic/core/session.rb
Instance Attribute Summary collapse
-
#by_id ⇒ Object
readonly
Returns the value of attribute by_id.
-
#by_value ⇒ Object
readonly
Returns the value of attribute by_value.
Instance Method Summary collapse
- #clear ⇒ Object
- #get_id(value) ⇒ Object
- #get_value(id) ⇒ Object
-
#initialize ⇒ MutableInternTable
constructor
A new instance of MutableInternTable.
- #register(value) ⇒ Object
Constructor Details
#initialize ⇒ MutableInternTable
Returns a new instance of MutableInternTable.
362 363 364 365 |
# File 'lib/twilic/core/session.rb', line 362 def initialize @by_value = {} @by_id = [] end |
Instance Attribute Details
#by_id ⇒ Object (readonly)
Returns the value of attribute by_id.
360 361 362 |
# File 'lib/twilic/core/session.rb', line 360 def by_id @by_id end |
#by_value ⇒ Object (readonly)
Returns the value of attribute by_value.
360 361 362 |
# File 'lib/twilic/core/session.rb', line 360 def by_value @by_value end |
Instance Method Details
#clear ⇒ Object
388 389 390 391 |
# File 'lib/twilic/core/session.rb', line 388 def clear @by_value = {} @by_id = [] end |
#get_id(value) ⇒ Object
367 368 369 370 |
# File 'lib/twilic/core/session.rb', line 367 def get_id(value) id = @by_value[value] id ? [id, true] : [0, false] end |
#get_value(id) ⇒ Object
372 373 374 375 376 |
# File 'lib/twilic/core/session.rb', line 372 def get_value(id) return ["", false] if id >= @by_id.length [@by_id[id], true] end |
#register(value) ⇒ Object
378 379 380 381 382 383 384 385 386 |
# File 'lib/twilic/core/session.rb', line 378 def register(value) id = @by_value[value] return id if id id = @by_id.length @by_value[value] = id @by_id << value id end |