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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bus) ⇒ RemoteTable

Returns a new instance of RemoteTable.



77
78
79
80
81
82
83
# File 'lib/remote_table.rb', line 77

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.



72
73
74
# File 'lib/remote_table.rb', line 72

def file
  @file
end

#packageObject

Returns the value of attribute package.



72
73
74
# File 'lib/remote_table.rb', line 72

def package
  @package
end

#requestObject

Returns the value of attribute request.



72
73
74
# File 'lib/remote_table.rb', line 72

def request
  @request
end

#tableObject

Returns the value of attribute table.



73
74
75
# File 'lib/remote_table.rb', line 73

def table
  @table
end

#transformObject

Returns the value of attribute transform.



72
73
74
# File 'lib/remote_table.rb', line 72

def transform
  @transform
end

Class Method Details

.cleanupObject



59
60
61
62
63
64
# File 'lib/remote_table.rb', line 59

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



66
67
68
69
# File 'lib/remote_table.rb', line 66

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

Instance Method Details

#<=>(other) ⇒ Object



97
98
99
# File 'lib/remote_table.rb', line 97

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

#eachObject Also known as: each_row



85
86
87
88
# File 'lib/remote_table.rb', line 85

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

#to_aObject Also known as: rows



91
92
93
94
# File 'lib/remote_table.rb', line 91

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