class FBO::File

Attributes

file[R]

Public Class Methods

filename_for_date(date) click to toggle source
# 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
new(filename) click to toggle source
# File lib/fbo/file.rb, line 17
def initialize(filename)
  @file = ::File.new(filename)
end

Public Instance Methods

contents() click to toggle source
# File lib/fbo/file.rb, line 26
def contents
  @contents ||= cleanup_data(@file.read)
end
gets() click to toggle source
# File lib/fbo/file.rb, line 21
def gets
  str = @file.gets
  str.nil? ? nil : cleanup_data(str)
end

Protected Instance Methods

cleanup_data(data) click to toggle source
# File lib/fbo/file.rb, line 32
def cleanup_data(data)
  data.encode('UTF-16le', :invalid => :replace, :replace => '')
      .encode('UTF-8')
      .gsub(/\r\n/, "\n")
      .gsub(/^M/, "")
end