Class: FBO::File

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fbo/file.rb

Direct Known Subclasses

ChunkedFile, RemoteFile, SegmentedFile

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ File

Returns a new instance of File.



17
18
19
# File 'lib/fbo/file.rb', line 17

def initialize(filename)
  @file = ::File.new(filename)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/fbo/file.rb', line 7

def file
  @file
end

Class Method Details

.filename_for_date(date) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
# File 'lib/fbo/file.rb', line 11

def filename_for_date(date)
  raise ArgumentError, "No date given for file" unless date
  "FBOFeed#{ date.strftime("%Y%m%d") }"
end

Instance Method Details

#contentsObject



26
27
28
# File 'lib/fbo/file.rb', line 26

def contents
  @contents ||= cleanup_data(@file.read)
end

#getsObject



21
22
23
24
# File 'lib/fbo/file.rb', line 21

def gets
  str = @file.gets
  str.nil? ? nil : cleanup_data(str)
end