Class: Andromeda::Cmd::Writer

Inherits:
FileCmdPlan show all
Defined in:
lib/andromeda/cmd.rb

Instance Attribute Summary

Attributes inherited from FileCmdPlan

#file, #mode, #path

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 FileCmdPlan

#data_key, #data_map, #data_tag, #data_val, #on_close, #on_open, #on_sync

Methods inherited from Kit::InlineKeyRouter

#key_spot

Methods inherited from Kit::SinglePlan

#init_guide

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

short_s, #to_s, #to_short_s

Methods inherited from Impl::ConnectorBase

#post, #post_local, #start

Constructor Details

This class inherits a constructor from Andromeda::Plan

Instance Method Details

#init_modeObject



123
# File 'lib/andromeda/cmd.rb', line 123

def init_mode ; 'w' end

#on_input(key, val) ⇒ Object

Raises:

  • (ArgumentError)


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  = tags[: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