Class: ReviewFetcher

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

Direct Known Subclasses

AndroidFetcher, AppleFetcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#platformObject

Returns the value of attribute platform.



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

def platform
  @platform
end

#processorsObject

Returns the value of attribute processors.



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

def processors
  @processors
end

Instance Method Details

#executeObject



13
14
15
# File 'lib/Models/ReviewFetcher.rb', line 13

def execute()

end

#getPlatformLatestCheckTimestampObject



40
41
42
43
44
45
46
47
# File 'lib/Models/ReviewFetcher.rb', line 40

def getPlatformLatestCheckTimestamp()
    filePath = "#{config.baseExecutePath}/latestCheckTimestamp/#{platform}"
    if File.exists?(filePath)
        return File.read(filePath).to_i
    else
        return 0
    end
end

#processReviews(reviews, platform) ⇒ Object



21
22
23
24
25
# File 'lib/Models/ReviewFetcher.rb', line 21

def processReviews(reviews, platform)
    processors.each do |processor|
        reviews = processor.processReviews(reviews, platform)
    end
end

#registerProcessor(processor) ⇒ Object



17
18
19
# File 'lib/Models/ReviewFetcher.rb', line 17

def registerProcessor(processor)
    processors.append(processor)
end

#sendWelcomMessageObject



27
28
29
30
31
32
# File 'lib/Models/ReviewFetcher.rb', line 27

def sendWelcomMessage()
    slackProcessor = processors.find { |processor| processor.is_a?(SlackProcessor) }
    if !slackProcessor.nil?
        slackProcessor.sendWelcomMessage(platform)
    end
end

#setPlatformLatestCheckTimestamp(timestamp) ⇒ Object



34
35
36
37
38
# File 'lib/Models/ReviewFetcher.rb', line 34

def setPlatformLatestCheckTimestamp(timestamp)
    basePath = "#{config.baseExecutePath}/latestCheckTimestamp/"
    Helper.createDirIfNotExist(basePath)
    File.open("#{basePath}/#{platform}", 'w') { |file| file.write(timestamp) }
end