Class: RemoteTable

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/remote_table.rb,
lib/remote_table/file.rb,
lib/remote_table/package.rb,
lib/remote_table/request.rb,
lib/remote_table/file/csv.rb,
lib/remote_table/file/ods.rb,
lib/remote_table/file/xls.rb,
lib/remote_table/file/html.rb,
lib/remote_table/file/xlsx.rb,
lib/remote_table/transform.rb,
lib/remote_table/file/fixed_width.rb,
lib/remote_table/file/roo_spreadsheet.rb

Defined Under Namespace

Modules: Csv, FixedWidth, Html, Ods, RooSpreadsheet, Xls, Xlsx Classes: File, Package, Request, Transform

Constant Summary collapse

MyCSV =
::FasterCSV

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bus) ⇒ RemoteTable

Returns a new instance of RemoteTable.



55
56
57
58
59
60
61
# File 'lib/remote_table.rb', line 55

def initialize(bus)
  @transform = Transform.new(bus)
  @package = Package.new(bus)
  @request = Request.new(bus)
  @file = File.new(bus)
  at_exit { RemoteTable.cleanup }
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



50
51
52
# File 'lib/remote_table.rb', line 50

def file
  @file
end

#packageObject

Returns the value of attribute package.



50
51
52
# File 'lib/remote_table.rb', line 50

def package
  @package
end

#requestObject

Returns the value of attribute request.



50
51
52
# File 'lib/remote_table.rb', line 50

def request
  @request
end

#tableObject

Returns the value of attribute table.



51
52
53
# File 'lib/remote_table.rb', line 51

def table
  @table
end

#transformObject

Returns the value of attribute transform.



50
51
52
# File 'lib/remote_table.rb', line 50

def transform
  @transform
end

Class Method Details

.cleanupObject



37
38
39
40
41
42
# File 'lib/remote_table.rb', line 37

def cleanup
  paths_for_removal.each do |path|
    FileUtils.rm_rf path
    paths_for_removal.delete path
  end if paths_for_removal.is_a?(Array)
end

.remove_at_exit(path) ⇒ Object



44
45
46
47
# File 'lib/remote_table.rb', line 44

def remove_at_exit(path)
  self.paths_for_removal ||= Array.new
  paths_for_removal.push path
end

Instance Method Details

#<=>(other) ⇒ Object



75
76
77
# File 'lib/remote_table.rb', line 75

def <=>(other)
  raise "Not implemented"
end

#eachObject Also known as: each_row



63
64
65
66
# File 'lib/remote_table.rb', line 63

def each
  finish_table! unless table
  table.each_row { |row| yield row }
end

#to_aObject Also known as: rows



69
70
71
72
# File 'lib/remote_table.rb', line 69

def to_a
  cache_rows! if @_row_cache.nil?
  @_row_cache
end