1

Hey this is my first post and I´m an complete ruby noob. This is my existing source-code for my Dashing/Roo Project.

require 'roo-xls'
SCHEDULER.every '10m' do
file_path = "/home/numbers.xlsx"
def fetch_spreadsheet_data(path)
s = Roo::Excelx.new(path)

#This should be edited
send_event('Department1',   { value:s.cell('C',5,s.sheets[0]) })  
end

#Checker if file has been modified
module Handler
  def file_modified
    fetch_spreadsheet_data(path)
  end
end

fetch_spreadsheet_data(file_path)
end

I want to add a few Departments (for example Department1, Factory2 ....)

For Department1 it should use: 'C',1,s.sheets[0]; For Factory2 it should use: 'C',2,s.sheets[0] and so on.

I want to save the names into an array and then iterate through it. So how could I implement this logic? thanks a lot

roflb0b
  • 11
  • 1
  • This is in dire need of proper indentation. Why are the module definition and the associated method definitions inside the loop? Put *only* your call inside the loop. – tadman Nov 27 '16 at 23:39
  • Hint: Add more arguments to `fetch_spreadsheet_data` to accommodate different locations. – tadman Nov 27 '16 at 23:41
  • But I want to use only one spreadsheet and iterate through diffrent cells like C1, C2, C3 and so on. – roflb0b Nov 28 '16 at 23:04
  • **Add more arguments**. I can't be more clear about this. You're trying to vary the behaviour of a method with parameters. This is how you do it. – tadman Nov 29 '16 at 00:44

0 Answers0