Class: FilterProcessor
- Defined in:
- lib/Processors/FilterProcessor.rb
Instance Attribute Summary collapse
-
#keywordsInclude ⇒ Object
Returns the value of attribute keywordsInclude.
-
#ratingsInclude ⇒ Object
Returns the value of attribute ratingsInclude.
-
#territoriesInclude ⇒ Object
Returns the value of attribute territoriesInclude.
Attributes inherited from Processor
#baseExecutePath, #config, #configFilePath
Instance Method Summary collapse
-
#initialize(config, configFilePath, baseExecutePath) ⇒ FilterProcessor
constructor
A new instance of FilterProcessor.
- #processReviews(reviews, platform) ⇒ Object
Constructor Details
#initialize(config, configFilePath, baseExecutePath) ⇒ FilterProcessor
Returns a new instance of FilterProcessor.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/Processors/FilterProcessor.rb', line 11 def initialize(config, configFilePath, baseExecutePath) @config = config @configFilePath = configFilePath @baseExecutePath = baseExecutePath @keywordsInclude = [] if !config["keywordsInclude"].nil? @keywordsInclude = config["keywordsInclude"] end @ratingsInclude = [] if !config["ratingsInclude"].nil? @ratingsInclude = config["ratingsInclude"] end @territoriesInclude = [] if !config["territoriesInclude"].nil? @territoriesInclude = config["territoriesInclude"] end puts "[FilterProcessor] Init Success." end |
Instance Attribute Details
#keywordsInclude ⇒ Object
Returns the value of attribute keywordsInclude.
9 10 11 |
# File 'lib/Processors/FilterProcessor.rb', line 9 def keywordsInclude @keywordsInclude end |
#ratingsInclude ⇒ Object
Returns the value of attribute ratingsInclude.
9 10 11 |
# File 'lib/Processors/FilterProcessor.rb', line 9 def @ratingsInclude end |
#territoriesInclude ⇒ Object
Returns the value of attribute territoriesInclude.
9 10 11 |
# File 'lib/Processors/FilterProcessor.rb', line 9 def territoriesInclude @territoriesInclude end |
Instance Method Details
#processReviews(reviews, platform) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/Processors/FilterProcessor.rb', line 34 def processReviews(reviews, platform) if reviews.length < 1 return reviews end if .length > 0 orgReviewsCount = reviews.length reviews = reviews.select{ |review| .map{ || .to_i }.include? review. } puts "[FilterProcessor] filter out ratings from #{orgReviewsCount} to #{reviews.length}" end if territoriesInclude.length > 0 orgReviewsCount = reviews.length reviews = reviews.select{ |review| territoriesInclude.map{ |territory| territory.upcase }.include? review.territory.upcase } puts "[FilterProcessor] filter out ratings from #{orgReviewsCount} to #{reviews.length}" end if keywordsInclude.length > 0 orgReviewsCount = reviews.length keywordsInclude.select{ |keywordsInclude| keywordsInclude != "" }.each do |keywordInclude| reviews = reviews.select{ |review| review.body.include? keywordInclude } end puts "[FilterProcessor] filter out ratings from #{orgReviewsCount} to #{reviews.length}" end return reviews end |