Module: Dap::Input::FileSource

Included in:
InputCSV, InputJSON, InputLines, InputWARC
Defined in:
lib/dap/input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fdObject

Returns the value of attribute fd.



16
17
18
# File 'lib/dap/input.rb', line 16

def fd
  @fd
end

Instance Method Details

#closeObject



24
25
26
27
# File 'lib/dap/input.rb', line 24

def close
  self.close if self.fd
  self.fd = nil
end

#open(file_name) ⇒ Object



18
19
20
21
22
# File 'lib/dap/input.rb', line 18

def open(file_name)
  close
  self.fd = ['-', 'stdin', nil].include?(file_name) ? 
    $stdin : ::File.open(file_name, "rb")
end