Class: RemoteTable::File

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_table/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bus) ⇒ File

Returns a new instance of File.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/remote_table/file.rb', line 6

def initialize(bus)
  @filename = bus[:filename]
  @format = bus[:format] || format_from_filename
  @delimiter = bus[:delimiter]
  @sheet = bus[:sheet] || 0
  @skip = bus[:skip] # rows
  @crop = bus[:crop] # rows
  @cut = bus[:cut]   # columns
  @headers = bus[:headers]
  @schema = bus[:schema]
  @schema_name = bus[:schema_name]
  @trap = bus[:trap]
  extend "RemoteTable::#{format.to_s.camelcase}".constantize
end

Instance Attribute Details

#cropObject

Returns the value of attribute crop.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def crop
  @crop
end

#cutObject

Returns the value of attribute cut.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def cut
  @cut
end

#delimiterObject

Returns the value of attribute delimiter.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def delimiter
  @delimiter
end

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def filename
  @filename
end

#formatObject

Returns the value of attribute format.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def format
  @format
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def headers
  @headers
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/remote_table/file.rb', line 4

def path
  @path
end

#schemaObject

Returns the value of attribute schema.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def schema
  @schema
end

#schema_nameObject

Returns the value of attribute schema_name.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def schema_name
  @schema_name
end

#sheetObject

Returns the value of attribute sheet.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def sheet
  @sheet
end

#skipObject

Returns the value of attribute skip.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def skip
  @skip
end

#trapObject

Returns the value of attribute trap.



3
4
5
# File 'lib/remote_table/file.rb', line 3

def trap
  @trap
end

Instance Method Details

#tabulate(path) ⇒ Object



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

def tabulate(path)
  define_fixed_width_schema! if format == :fixed_width and schema.is_a?(Array) # TODO move to generic subclass callback
  self.path = path
  self
end