Class: Andromeda::Cmd::Writer
- Inherits:
-
FileCmdPlan
- Object
- Impl::ConnectorBase
- Impl::ProtoPlan
- Plan
- Kit::SinglePlan
- Kit::InlineKeyRouter
- FileCmdPlan
- Andromeda::Cmd::Writer
- Defined in:
- lib/andromeda/cmd.rb
Instance Attribute Summary
Attributes inherited from FileCmdPlan
Attributes inherited from Plan
#error_level, #log, #marker, #nick, #trace_enter, #trace_exit
Attributes inherited from Impl::ProtoPlan
Instance Method Summary collapse
Methods inherited from FileCmdPlan
#data_key, #data_map, #data_tag, #data_val, #on_close, #on_open, #on_sync
Methods inherited from Kit::InlineKeyRouter
Methods inherited from Kit::SinglePlan
Methods inherited from Plan
#initialize, #initialize_copy, #on_enter, #pool, #tap, #to_short_s
Methods inherited from Impl::ProtoPlan
#>>, #current_name, #current_scope, #data_key, #data_tag, #data_val, #dest, #entry, #init_guide, #initialize, #initialize_copy, #key_label, #key_spot, #map_data, #mute, name_spot, #post_data, #post_to, #public_spot, #selects?, #signal_name?, signal_names, #signal_names, signal_spot, spot_attr, #spot_attr_name?, spot_attr_names, #spot_attr_names, spot_meth, #spot_meth_name?, spot_meth_names, #spot_meth_names, #spot_name?, spot_names, #spot_names, #tags, #to_short_s, #via
Methods included from Impl::To_S
Methods inherited from Impl::ConnectorBase
Constructor Details
This class inherits a constructor from Andromeda::Plan
Instance Method Details
#init_mode ⇒ Object
123 |
# File 'lib/andromeda/cmd.rb', line 123 def init_mode ; 'w' end |
#on_input(key, val) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/andromeda/cmd.rb', line 125 def on_input(key, val) signal_error ArgumentError.new("associated filed not open") unless file cmd = val.cmd raise ArgumentError, "invalid cmd" unless cmd.kind_of?(Symbol) data = val.data str = if data then data.to_json else '' end len = str.length + 1 tim = val.time if val.time tim = Time.now unless tim tim = tim.to_i unless tim.kind_of?(Fixnum) new_str = '' str.each_line { |line| new_str << "... #{line}\n" } str = nil len = new_str.length val = [:comment] val.each_line { |line| file.write "\# #{line}\n" } if val file.write "<<< ANDROMEDA START :#{cmd} TIME #{tim} LEN #{len} >>>\n" file.write new_str file.write "<<< ANDROMEDA END :#{cmd} >>>\n" super key, val end |