class FlatKit::Input::File
Attributes
count[R]
path[R]
Public Class Methods
handles?(obj)
click to toggle source
# File lib/flat_kit/input/file.rb, line 9 def self.handles?(obj) return true if obj.instance_of?(Pathname) return false unless obj.instance_of?(String) # incase these get loaded in different orders return false if ::FlatKit::Input::IO.is_stdin?(obj) return true end
new(obj)
click to toggle source
# File lib/flat_kit/input/file.rb, line 19 def initialize(obj) @count = 0 @path = Pathname.new(obj) raise FlatKit::Error, "Input #{obj} is not readable" unless @path.readable? @io = open_input(path) end
Public Instance Methods
close()
click to toggle source
# File lib/flat_kit/input/file.rb, line 30 def close @io.close end
io()
click to toggle source
# File lib/flat_kit/input/file.rb, line 34 def io @io end
name()
click to toggle source
# File lib/flat_kit/input/file.rb, line 26 def name path.to_s end
Private Instance Methods
open_input(path)
click to toggle source
open the opropriate input type depending on the source file name
TODO: add in bzip
# File lib/flat_kit/input/file.rb, line 43 def open_input(path) case path.extname when ".gz" Zlib::GzipReader.open(path.to_s) else path.open("rb") end end