rubymine - run a ruby project on ruby mine -


i new ruby programming. wrote little program recursively count blobs in 2 dimensional array. contains 2 classes, cell , blobs. getting following error , dont know means or how fix it.

attached code , error. cell class

class cell    attr_accessor :data,:visited,:row,:col     def initialize(data, row, col)       @data = data       @visited = false       @row = row       @col = col   end    def to_s     self.data.to_s   end  end 

blob class

class blobs  require ./cell  @cells = array.new(10){array.new(10)}   def separate(percentage)    in 0..10      in 0..10        random = random.rand(0,100)        if random < percentage          @cells[i][j] = cell.new('x',i,j)        else          @cells[i][j] = cell.new(nil, i, j)        end      end    end  end   def markblob(currentcell)    if currentcell.visited      return    end    currentcell.visited = true    if currentcell.data.nil?      return    end     if currentcell.row >0      markblob(@cells[currentcell.row-1][currentcell.col])    end     if currentcell.row <@cells.size-1      markblob(@cells[currentcell.row+1][currentcell.col])    end     if currentcell.col>0      markblob(@cells[currentcell.row][currentcell.col-1])    end     if currentcell.col<@cells.size-1      markblob(@cells[currentcell.row][currentcell.col+1])    end   end   def countblobs    count = 0    in 0..10      j in 0..10        cell = @cells[i][j]        if !cell.visited && cell.data.nil?          count++          markblob(cell)        end      end    end    return count  end   def to_s    in 0..10      j in 0..10        if @cells[i][j].data.nil?          puts '- '        else        puts @cells[i][j].data + ' '          end      end      puts "\n"    end   end   blob = blobs.new  number = blob  puts number    end 

this error getting:

c:\ruby22\bin\ruby.exe -e         $stdout.sync=true;$stderr.sync=true;load($0=argv.shift)         c:/users/nechama/rubymineprojects/blobs/blobs.rb c:/ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:38:in   `require': wrong number of arguments (0 1) (argumenterror)     c:/users/nechama/rubymineprojects/blobs/blobs.rb:3:in `<class:blobs>'     c:/users/nechama/rubymineprojects/blobs/blobs.rb:2:in `<top (required)>'     -e:1:in `load'     -e:1:in `<main>'  process finished exit code 1 

require should string argument.

use require_relative cell file

require_relative 'cell' 

and put above class blobs.

more including other files in ruby


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -