Class: Andromeda::Kit::Tee

Inherits:
Plan show all
Defined in:
lib/andromeda/kit.rb

Instance Attribute Summary collapse

Attributes inherited from Plan

#error_level, #log, #marker, #nick, #trace_enter, #trace_exit

Attributes inherited from Impl::ProtoPlan

#guide, #id

Instance Method Summary collapse

Methods inherited from Plan

#pool, #tap, #to_short_s

Methods inherited from Impl::ProtoPlan

#>>, attr_spot, #attr_spot_name?, attr_spot_names, #attr_spot_names, #current_name, #current_scope, #data_key, #data_map, #data_tag, #data_val, #dest, #entry, #init_guide, #key_label, #key_spot, meth_spot, #meth_spot_name?, #meth_spot_names, meth_spot_names, #mute, name_spot, #post_data, #post_to, #public_spot, #selects?, #signal_name?, signal_names, #signal_names, signal_spot, #spot_name?, #spot_names, spot_names, #tags, #to_short_s, #via

Methods included from Impl::To_S

short_s, #to_s, #to_short_s

Methods inherited from Impl::ConnectorBase

#post, #post_local, #start

Constructor Details

#initialize(config = {}) ⇒ Tee

Returns a new instance of Tee.



27
28
29
30
31
32
33
# File 'lib/andromeda/kit.rb', line 27

def initialize(config = {})
	config = { nick: config } unless config.is_a? Hash || config.is_a?(Spot)
	config = { other: config } unless config.is_a? Hash
	super config

	@level ||= :info
end

Instance Attribute Details

#delayObject

Returns the value of attribute delay.



25
26
27
# File 'lib/andromeda/kit.rb', line 25

def delay
  @delay
end

#levelObject

Returns the value of attribute level.



23
24
25
# File 'lib/andromeda/kit.rb', line 23

def level
  @level
end

#otherObject

Returns the value of attribute other.



24
25
26
# File 'lib/andromeda/kit.rb', line 24

def other
  @other
end

Instance Method Details

#initialize_copy(other) ⇒ Object



35
36
37
38
# File 'lib/andromeda/kit.rb', line 35

def initialize_copy(other)
	@level = other.level.identical_copy
	@delay = other.delay.identical_copy
end

#on_enter(key, val) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/andromeda/kit.rb', line 40

def on_enter(key, val)
	log_   = log
	level_ = level
	sleep delay.to_i if delay
	if log_ && level_
		cur_name = current_name
		key_str  = Andromeda::Impl::To_S.short_s key
		val_str  = Andromeda::Impl::To_S.short_s val
		log_str  = "#{to_s}.#{cur_name}(#{key_str}, #{val_str})"
		tags.each_pair { |k, v|	log_str << " #{k}=#{Andromeda::Impl::To_S.short_s(v)}" }
		log_str << " tid=0x#{Thread.current.object_id.to_s(16)}"
		log_.send level, log_str
	end
	other_ = other
	other_ << val if other_
	super key, val
end