Class: Sheetsy::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/sheetsy/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Reader

Returns a new instance of Reader.



7
8
9
10
# File 'lib/sheetsy/reader.rb', line 7

def initialize(source, options = {})
  @source = source
  @options = options
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/sheetsy/reader.rb', line 5

def data
  @data
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/sheetsy/reader.rb', line 5

def options
  @options
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/sheetsy/reader.rb', line 5

def source
  @source
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/sheetsy/reader.rb', line 28

def debug?
  @debug ||= options[:debug]
end

#overwrite?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/sheetsy/reader.rb', line 24

def overwrite?
  @overwrite ||= options[:overwrite]
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sheetsy/reader.rb', line 12

def run
  debug "Files found: #{files.count}"

  progress_bar.progress = 0

  @data = files.map do |file|
    ret = JSONFile.new(file)
    progress_bar.increment
    ret
  end
end