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.



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

def fd
  @fd
end

Instance Method Details

#closeObject



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

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

#open(file_name) ⇒ Object



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

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