Class: Twilic::Core::Session::InternTable
- Inherits:
-
Data
- Object
- Data
- Twilic::Core::Session::InternTable
- 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.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#by_id ⇒ Object (readonly)
Returns the value of attribute by_id
44 45 46 |
# File 'lib/twilic/core/session.rb', line 44 def by_id @by_id end |
#by_value ⇒ Object (readonly)
Returns the value of attribute by_value
44 45 46 |
# File 'lib/twilic/core/session.rb', line 44 def by_value @by_value end |
Class Method Details
.new_table ⇒ Object
45 46 47 |
# File 'lib/twilic/core/session.rb', line 45 def self.new_table new(by_value: {}, by_id: []) end |
Instance Method Details
#clear ⇒ Object
68 69 70 |
# File 'lib/twilic/core/session.rb', line 68 def clear new(by_value: {}, by_id: []) end |
#get_id(value) ⇒ Object
49 50 51 52 |
# File 'lib/twilic/core/session.rb', line 49 def get_id(value) id = by_value[value] id ? [id, true] : [0, false] end |
#get_value(id) ⇒ Object
54 55 56 57 58 |
# File 'lib/twilic/core/session.rb', line 54 def get_value(id) return ["", false] if id >= by_id.length [by_id[id], true] end |
#register(value) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/twilic/core/session.rb', line 60 def register(value) id, ok = get_id(value) return id if ok id = by_id.length new(by_value: by_value.merge(value => id), by_id: by_id + [value]) end |