Class: Andromeda::Cmd::FileCmdPlan

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

Direct Known Subclasses

Writer

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 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, #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 Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



50
51
52
# File 'lib/andromeda/cmd.rb', line 50

def file
  @file
end

#modeObject (readonly)

Returns the value of attribute mode.



49
50
51
# File 'lib/andromeda/cmd.rb', line 49

def mode
  @mode
end

#pathObject (readonly)

Returns the value of attribute path.



48
49
50
# File 'lib/andromeda/cmd.rb', line 48

def path
  @path
end

Instance Method Details

#data_key(name, data) ⇒ Object



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

def data_key(name, data) ; data.cmd  end

#data_map(name, data) ⇒ Object



61
62
63
# File 'lib/andromeda/cmd.rb', line 61

def data_map(name, data)
  if data.is_a?(Cmd) then data else Cmd.new(data) end
end

#data_tag(name, key, val, tags_in) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/andromeda/cmd.rb', line 68

def data_tag(name, key, val, tags_in)
  tags_out = super
  if name == :input
    tags_out[:time]    = val.time
    tags_out[:comment] = val.comment
  end
  tags_out
end

#data_val(name, data) ⇒ Object



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

def data_val(name, data) ; data.data end

#on_close(key, val) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/andromeda/cmd.rb', line 96

def on_close(key, val)
  if @file
    begin
      close_file(@file)
    ensure
      @file = nil
    end
  else
    signal_error ArgumentError.new("associated file not open")
  end
end

#on_input(key, val) ⇒ Object



88
89
90
# File 'lib/andromeda/cmd.rb', line 88

def on_input(key, val)
  exit << val if exit
end

#on_open(key, val) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/andromeda/cmd.rb', line 77

def on_open(key, val)
  if @file
    signal_error ArgumentError.new("associated file already open")
  else
    @path   = val[:path] if val[:path]
    @mode   = val[:mode] if val[:mode]
    @mode ||= init_mode
    @file = File.open @path, @mode
  end
end

#on_sync(key, val) ⇒ Object



92
93
94
# File 'lib/andromeda/cmd.rb', line 92

def on_sync(key, val)
  f = @file ; sync_file f if f
end