Class: Kibuvits_krl171bt4_msgc_stack
- Inherits:
-
Object
- Object
- Kibuvits_krl171bt4_msgc_stack
- Defined in:
- lib/kibuvits_ruby_library_krl171bt4_.rb
Overview
The Kibuvits_krl171bt4_msgc_stack partly mimics an Array that accepts only elements that are of type Kibuvits_krl171bt4_msgc.
Constant Summary collapse
- @@s_version =
The field s_version is a freeform string that depicts a signature to all of the rest of the fields in the package, recursively. That is to say the s_version has to change whenever the class of the serializable instance changes or the serialization format changes.
"2:ProgFTE".freeze
Instance Attribute Summary collapse
-
#fdr_instantiation_timestamp ⇒ Object
readonly
Returns the value of attribute fdr_instantiation_timestamp.
-
#s_instance_id ⇒ Object
readonly
Returns the value of attribute s_instance_id.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(msgc_or_msgcs) ⇒ Object
-
#[](i_index) ⇒ Object
———————————————————————–.
-
#assert_lack_of_failures(s_optional_error_message_suffix = nil) ⇒ Object
Throws, if self.b_failure()==true.
-
#b_failure ⇒ Object
b_failure of the stack is a disjunction of its elements’ b_failure fields.
- #clear ⇒ Object
-
#cre(s_default_msg = $kibuvits_krl171bt4_lc_emptystring, s_message_id = "message code not set", b_failure = true, s_location_marker_GUID = $kibuvits_krl171bt4_lc_emptystring, s_default_language = $kibuvits_krl171bt4_lc_English) ⇒ Object
Adds a Kibuvits_krl171bt4_msgc instance to the stack.
-
#each ⇒ Object
last.
-
#first ⇒ Object
Like the Array.first.
-
#initialize ⇒ Kibuvits_krl171bt4_msgc_stack
constructor
A new instance of Kibuvits_krl171bt4_msgc_stack.
-
#last ⇒ Object
Like the Array.last.
- #length ⇒ Object
-
#push(msgc_or_msgcs) ⇒ Object
<<.
- #s_serialize ⇒ Object
-
#to_s(s_language = nil) ⇒ Object
———————————————————————–.
Constructor Details
#initialize ⇒ Kibuvits_krl171bt4_msgc_stack
Returns a new instance of Kibuvits_krl171bt4_msgc_stack.
3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3369 def initialize @fdr_instantiation_timestamp=Time.now.to_r @ar_elements=Array.new @ht_element_ids=Hash.new @ht_element_insertion_times=Hash.new @s_instance_id="msgcs_"+Kibuvits_krl171bt4_wholenumberID_generator.generate.to_s+"_"+ Kibuvits_krl171bt4_GUID_generator.generate_GUID @mx=Mutex.new @ob_instantiation_time=Time.now end |
Instance Attribute Details
#fdr_instantiation_timestamp ⇒ Object (readonly)
Returns the value of attribute fdr_instantiation_timestamp.
3367 3368 3369 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3367 def @fdr_instantiation_timestamp end |
#s_instance_id ⇒ Object (readonly)
Returns the value of attribute s_instance_id.
3366 3367 3368 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3366 def s_instance_id @s_instance_id end |
Class Method Details
.ob_deserialize(s_progfte) ⇒ Object
3600 3601 3602 3603 3604 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3600 def Kibuvits_krl171bt4_msgc_stack.ob_deserialize(s_progfte) msgcs=Kibuvits_krl171bt4_msgc_stack.new msgcs.send(:ob_deserialize,s_progfte) return msgcs end |
Instance Method Details
#<<(msgc_or_msgcs) ⇒ Object
3453 3454 3455 3456 3457 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3453 def <<(msgc_or_msgcs) bn=binding() kibuvits_krl171bt4_typecheck bn, [Kibuvits_krl171bt4_msgc,Kibuvits_krl171bt4_msgc_stack], msgc_or_msgcs insert_originedited_msgc_or_msgcs(msgc_or_msgcs) end |
#[](i_index) ⇒ Object
3669 3670 3671 3672 3673 3674 3675 3676 3677 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3669 def [](i_index) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_typecheck bn, Fixnum, i_index kibuvits_krl171bt4_assert_arrayix(bn,@ar_elements,i_index) end # if msgc_or_msgcs=@ar_elements[i_index] return msgc_or_msgcs end |
#assert_lack_of_failures(s_optional_error_message_suffix = nil) ⇒ Object
Throws, if self.b_failure()==true
3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3653 def assert_lack_of_failures(=nil) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_typecheck bn, [NilClass,String], end # if if b_failure s_msg=$kibuvits_krl171bt4_lc_linebreak+to_s()+$kibuvits_krl171bt4_lc_linebreak if .class==String s_msg<<(+$kibuvits_krl171bt4_lc_linebreak) end # if kibuvits_krl171bt4_throw(s_msg) end # if end |
#b_failure ⇒ Object
b_failure of the stack is a disjunction of its elements’ b_failure fields.
3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3382 def b_failure # The reason, why it's a recursive method # in stead of an instance variable is that the # Kibuvits_krl171bt4_msgc instances that reside within some # Kibuvits_krl171bt4_msgc_stack instance that is an element of # self have references in other places and the state change # of the sub-sub-etc. elements has to be taken to # account in the self.b_failure() output, but the # update mechanism would probably be # computationally relatively expensive and code-verbose. # Hence one prefers to pay just the computational expense and # save oneself from the code-verbose part. b_out=false @ar_elements.each do |msgc_or_msgcs| if msgc_or_msgcs.b_failure b_out=true break end # if end # loop return b_out end |
#clear ⇒ Object
3476 3477 3478 3479 3480 3481 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3476 def clear @mx.synchronize do @ar_elements.clear @ht_element_ids.clear end # synchronize end |
#cre(s_default_msg = $kibuvits_krl171bt4_lc_emptystring, s_message_id = "message code not set", b_failure = true, s_location_marker_GUID = $kibuvits_krl171bt4_lc_emptystring, s_default_language = $kibuvits_krl171bt4_lc_English) ⇒ Object
Adds a Kibuvits_krl171bt4_msgc instance to the stack. Arguments match with the Kibuvits_krl171bt4_msgc constructor arguments.
3466 3467 3468 3469 3470 3471 3472 3473 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3466 def cre(s_default_msg=$kibuvits_krl171bt4_lc_emptystring, ="message code not set", b_failure=true,s_location_marker_GUID=$kibuvits_krl171bt4_lc_emptystring, s_default_language=$kibuvits_krl171bt4_lc_English) msgc=Kibuvits_krl171bt4_msgc.new(s_default_msg,,b_failure, s_default_language,s_location_marker_GUID) self<<msgc end |
#each ⇒ Object
last
3697 3698 3699 3700 3701 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3697 def each @ar_elements.each do |msgc_or_msgcs| yield msgc_or_msgcs end # loop end |
#first ⇒ Object
Like the Array.first. It returns nil, if the array is empty.
3683 3684 3685 3686 3687 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3683 def first msgc_or_msgcs=nil @mx.synchronize{msgc_or_msgcs=@ar_elements.first} return msgc_or_msgcs end |
#last ⇒ Object
Like the Array.last. It returns nil, if the array is empty.
3691 3692 3693 3694 3695 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3691 def last msgc_or_msgcs=nil @mx.synchronize{msgc_or_msgcs=@ar_elements.last} return msgc_or_msgcs end |
#length ⇒ Object
3484 3485 3486 3487 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3484 def length i=@ar_elements.length.to_i return i end |
#push(msgc_or_msgcs) ⇒ Object
<<
3459 3460 3461 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3459 def push(msgc_or_msgcs) self << msgc_or_msgcs end |
#s_serialize ⇒ Object
3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3490 def s_serialize ht_elems=Hash.new ht_elem_container=Hash.new i_number_of_elements=nil @mx.synchronize do i_number_of_elements=@ar_elements.size s_elem_instance_id=nil i_number_of_elements.times do |i| msgc_or_msgcs=@ar_elements[i] ht_elem_container[$kibuvits_krl171bt4_lc_s_type]=msgc_or_msgcs.class.to_s ht_elem_container[$kibuvits_krl171bt4_lc_s_serialized]=msgc_or_msgcs.s_serialize ht_elems[i.to_s]=Kibuvits_krl171bt4_ProgFTE.from_ht(ht_elem_container) ht_elem_container.clear end # loop end # synchronize ht_elems["si_number_of_elements"]=i_number_of_elements.to_s ht_instance=Hash.new ht_instance["s_ht_elems_progfte"]=Kibuvits_krl171bt4_ProgFTE.from_ht(ht_elems) ht_instance["sfdr_instantiation_timestamp"]=@fdr_instantiation_timestamp.to_s ht_instance["s_instance_id"]=@s_instance_id ht_instance["s_ht_element_ids_progfte"]=Kibuvits_krl171bt4_ProgFTE.from_ht(@ht_element_ids) ht_container=Hash.new ht_container[$kibuvits_krl171bt4_lc_s_version]=@@s_version ht_container[$kibuvits_krl171bt4_lc_s_type]="Kibuvits_krl171bt4_msgc_stack" ht_container[$kibuvits_krl171bt4_lc_s_serialized]=Kibuvits_krl171bt4_ProgFTE.from_ht(ht_instance) s_progfte=Kibuvits_krl171bt4_ProgFTE.from_ht(ht_container) return s_progfte end |
#to_s(s_language = nil) ⇒ Object
3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 3608 def to_s(s_language=nil) kibuvits_krl171bt4_typecheck binding(), [NilClass,String], s_language s_0=$kibuvits_krl171bt4_lc_emptystring s_1=nil b_prefix_with_linebreak=false rgx_1=/[\n\r]+$/ @mx.synchronize do @ar_elements.each do |msgc_or_msgcs| # The braces is to use smaller temporary strings, which # are better than longer ones in terms of CPU cache misses. if b_prefix_with_linebreak s_0=s_0+($kibuvits_krl171bt4_lc_linebreak+ msgc_or_msgcs.to_s(s_language).sub(rgx_1,$kibuvits_krl171bt4_lc_emptystring)) else s_0=s_0+( msgc_or_msgcs.to_s(s_language).sub(rgx_1,$kibuvits_krl171bt4_lc_emptystring)) b_prefix_with_linebreak=true end # if end # loop end # synchronize # "".each_line{|x| kibuvits_krl171bt4_writeln("["+x.sub(/[\n\r]$/,"")+"]")} outputs only "", not "[]" # "hi\nthere".each_line{|x| kibuvits_krl171bt4_writeln("["+x.sub(/[\n\r]$/,"")+"]")} outputs "[hi]\n[there]\n" s_1=$kibuvits_krl171bt4_lc_emptystring s_lc_spaces=$kibuvits_krl171bt4_lc_space*2 rgx_2=/([\s]|[\n\r])+$/ s_0.each_line do |s_line| if 0<((s_line.sub(rgx_2,$kibuvits_krl171bt4_lc_emptystring)).length) # The idea is that the very last line contains # just a line break, which means that without this # if-clause the "\n" is replaced with the s_1+(s_lc_spaces+"\n") s_1=s_1+(s_lc_spaces+s_line) end # if end # loop if @x_data!=nil # TODO: implement a serializationmodem mechanism for # the @x_data so that it also has a to_s method. s_1=s_1+"\n\n"+@x_data.to_s end # if s_1<<$kibuvits_krl171bt4_lc_doublelinebreak return s_1 end |