class Andromeda::Cmd::Cmd::FileCmdPlan

Attributes

file[R]
mode[R]
path[R]

Public Instance Methods

data_key(name, data) click to toggle source
# File lib/andromeda/cmd.rb, line 65
def data_key(name, data) ; data.cmd  end
data_map(name, data) click to toggle source
# 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) click to toggle source
Calls superclass method
# 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) click to toggle source
# File lib/andromeda/cmd.rb, line 66
def data_val(name, data) ; data.data end
on_close(key, val) click to toggle source
# 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) click to toggle source
# File lib/andromeda/cmd.rb, line 88
def on_input(key, val)
  exit << val if exit
end
on_open(key, val) click to toggle source
# 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) click to toggle source
# File lib/andromeda/cmd.rb, line 92
def on_sync(key, val)
  f = @file ; sync_file f if f
end

Protected Instance Methods

close_file(f) click to toggle source
# File lib/andromeda/cmd.rb, line 110
def close_file(f)
  begin
    sync_file f
  ensure
    f.close
  end
end
sync_file(f) click to toggle source
# File lib/andromeda/cmd.rb, line 118
def sync_file(f) ; end