Class: Kibuvits_krl171bt4_IDstamp_registry_t1
- Inherits:
-
Object
- Object
- Kibuvits_krl171bt4_IDstamp_registry_t1
- Defined in:
- lib/kibuvits_ruby_library_krl171bt4_.rb
Overview
The idea is that there’s a set of ID-name-ID-value pairs , i.e. a registry of ID-s, and one writes the ID-values out into the wild. The wilderness might be a set of documents, communication packets, communication sessions, etc.
The question that the instances of the Kibuvits_krl171bt4_IDstamp_registry_t1 help to answer is: Has an ID in the registry or in the wild chanted after the event, where the ID got copied from the registry to the wild?
ID-s are usually assembled by concating Globally Unique Identifiers with some other strings and postprocessing the resultant string.
Instance Attribute Summary collapse
-
#s_default_ID_prefix ⇒ Object
readonly
Returns the value of attribute s_default_ID_prefix.
Instance Method Summary collapse
-
#b_xor_registry2wild(ht_wild, s_id_name) ⇒ Object
Returns true, if the ht_wild differs from the ID in the registry.
-
#b_xor_wild2registry(ht_wild, s_id_name) ⇒ Object
Returns true, if the ht_wild differs from the ID in the registry.
-
#clear ⇒ Object
———————————————————————–.
-
#initialize(s_default_ID_prefix = "x", b_nil_from_wilderness_differs_from_registry_entries = false) ⇒ Kibuvits_krl171bt4_IDstamp_registry_t1
constructor
The s_default_ID_prefix must adhere to the rules of variable names.
-
#reset(s_id_name) ⇒ Object
Generates a new value for the ID in the registry.
-
#s_get(s_id_name) ⇒ Object
reset.
-
#s_get_ID_prefix(s_id_name) ⇒ Object
set_ID_prefix.
-
#set(s_id_name, s_id) ⇒ Object
ID-s must adhere to the rules of variable names.
-
#set_ID_prefix(s_id_name, s_id_prefix) ⇒ Object
ID-s can have heir private prefixes that override the default ID prefix.
Constructor Details
#initialize(s_default_ID_prefix = "x", b_nil_from_wilderness_differs_from_registry_entries = false) ⇒ Kibuvits_krl171bt4_IDstamp_registry_t1
The s_default_ID_prefix must adhere to the rules of variable names.
8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8683 def initialize(s_default_ID_prefix="x", b_nil_from_wilderness_differs_from_registry_entries=false) bn=binding() if KIBUVITS_krl171bt4_b_DEBUG kibuvits_krl171bt4_typecheck bn, String, s_default_ID_prefix kibuvits_krl171bt4_typecheck bn, [TrueClass,FalseClass], b_nil_from_wilderness_differs_from_registry_entries end # if kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_default_ID_prefix) @s_default_ID_prefix=($kibuvits_krl171bt4_lc_emptystring+s_default_ID_prefix).freeze @b_nil_from_wilderness_differs_from_registry_entries=b_nil_from_wilderness_differs_from_registry_entries @ht_registry=Hash.new @ht_prefixes=Hash.new end |
Instance Attribute Details
#s_default_ID_prefix ⇒ Object (readonly)
Returns the value of attribute s_default_ID_prefix.
8678 8679 8680 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8678 def s_default_ID_prefix @s_default_ID_prefix end |
Instance Method Details
#b_xor_registry2wild(ht_wild, s_id_name) ⇒ Object
8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8776 def b_xor_registry2wild(ht_wild,s_id_name) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_typecheck bn, Hash, ht_wild kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) end # if b_out=true if !@ht_registry.has_key? s_id_name # nil from registry and <whatever_value_from_the_wild> always differ. s_id_wild=$kibuvits_krl171bt4_lc_underscore s_id_wild=ht_wild[s_id_name] if ht_wild.has_key? s_id_name s_id_registry=generate_ID(s_id_name,s_id_wild) set(s_id_name,s_id_registry) s_id_registry=s_get(s_id_name) # to be consistent ht_wild[s_id_name]=s_id_registry return b_out end # if s_id_registry=s_get(s_id_name) if !ht_wild.has_key? s_id_name ht_wild[s_id_name]=s_id_registry b_out=@b_nil_from_wilderness_differs_from_registry_entries return b_out end # if s_id_wild=ht_wild[s_id_name] if s_id_wild==s_id_registry b_out=false else ht_wild[s_id_name]=s_id_registry end # if return b_out end |
#b_xor_wild2registry(ht_wild, s_id_name) ⇒ Object
Returns true, if the ht_wild differs from the ID in the registry. Performs the operation of: self.set(s_id_name,ht_wild)
Throws, if the ht_wild is not a string that conforms to variable name requirements.
8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8814 def b_xor_wild2registry(ht_wild,s_id_name) bn=binding() # Outside of the if due to multiple uses. if KIBUVITS_krl171bt4_b_DEBUG kibuvits_krl171bt4_typecheck bn, Hash, ht_wild kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) end # if if !ht_wild.has_key? s_id_name kibuvits_krl171bt4_throw("\n\nht_wild is missing the key \""+s_id_name+ "\nGUID='6f75661d-bba0-4d4d-951e-c13290a118e7'\n\n") end # if s_id_wild=ht_wild[s_id_name] # Hash[<nonexisting_key>] does not throw, but returns nil cl=s_id_wild.class if cl!=String # Includes the case, where s_id_wild==nil # The reason, why an exception is thrown here # in stead of just branching according to the # @b_nil_from_wilderness_differs_from_registry_entries # is that if the ht_wild has nil paired to the <s_id_name>, # then it's likely that the application code that wrote the # value to the ht_wild is faulty. A general requirement # is that the ht_wild[s_id_name] meets variable name requirements. kibuvits_krl171bt4_throw("\n\nht_wild does contain the key \""+s_id_name+ ", but it is not paired with a string.\n"+ "s_id_wild.class=="+cl.to_s+ "\ns_id_wild=="+s_id_wild.to_s+ "\nGUID='04a5aa44-6f3a-4db2-b50e-c13290a118e7'\n\n") end # if kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_wild) if KIBUVITS_krl171bt4_b_DEBUG reset(s_id_name) if !@ht_registry.has_key? s_id_name s_id_registry=@ht_registry[s_id_name] b_out=(s_id_wild!=s_id_registry) set(s_id_name,s_id_wild) return b_out end |
#clear ⇒ Object
8850 8851 8852 8853 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8850 def clear @ht_registry.clear @ht_prefixes.clear end |
#reset(s_id_name) ⇒ Object
Generates a new value for the ID in the registry.
8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8747 def reset(s_id_name) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) end # if s_id_registry=nil if @ht_registry.has_key? s_id_name s_id_registry=@ht_registry[s_id_name] else s_id_registry=$kibuvits_krl171bt4_lc_underscore end # if @ht_registry[s_id_name]=(generate_ID(s_id_name,s_id_registry)).freeze end |
#s_get(s_id_name) ⇒ Object
reset
8761 8762 8763 8764 8765 8766 8767 8768 8769 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8761 def s_get(s_id_name) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) end # if reset(s_id_name) if !@ht_registry.has_key? s_id_name s_out=@ht_registry[s_id_name] return s_out end |
#s_get_ID_prefix(s_id_name) ⇒ Object
set_ID_prefix
8708 8709 8710 8711 8712 8713 8714 8715 8716 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8708 def s_get_ID_prefix(s_id_name) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) end # if s_out=@s_default_ID_prefix s_out=@ht_prefixes[s_id_name] if @ht_prefixes.has_key? s_id_name return s_out end |
#set(s_id_name, s_id) ⇒ Object
ID-s must adhere to the rules of variable names.
8737 8738 8739 8740 8741 8742 8743 8744 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8737 def set(s_id_name,s_id) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id) end # if @ht_registry[s_id_name]=($kibuvits_krl171bt4_lc_emptystring+s_id).freeze end |
#set_ID_prefix(s_id_name, s_id_prefix) ⇒ Object
ID-s can have heir private prefixes that override the default ID prefix. ID-s, including their prefixes, must adhere to the rules of variable names.
8699 8700 8701 8702 8703 8704 8705 8706 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 8699 def set_ID_prefix(s_id_name,s_id_prefix) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_name) kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(bn,s_id_prefix) end # if @ht_prefixes[s_id_name]=($kibuvits_krl171bt4_lc_emptystring+s_id_prefix).freeze end |