Class: RightmoveWrangler::Processor

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

Constant Summary collapse

IMAGE_REGEX =
/\.(jpg|jpeg|png|gif)/i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Processor

Returns a new instance of Processor.



14
15
16
17
# File 'lib/rightmove_wrangler.rb', line 14

def initialize(args)
  @args = args
  @options = {}
end

Instance Attribute Details

#directory_listObject

Returns the value of attribute directory_list.



11
12
13
# File 'lib/rightmove_wrangler.rb', line 11

def directory_list
  @directory_list
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rightmove_wrangler.rb', line 19

def run
  @opts = OptionParser.new(&method(:set_opts))
  @opts.parse!(@args)
  $stdout.puts @options.inspect
  if @options.empty? || @options[:path].nil? || !File.directory?(@options[:path])
    $stderr.puts 'Invalid path specified'
    exit 1
  else
    loop do
      begin
        process!
      rescue Exception => ex
        raise ex if @options[:trace] || SystemExit === ex
        $stderr.print "#{ex.class}: " if ex.class != RuntimeError
        $stderr.puts ex.message
      end
      sleep 5
    end
  end
end