forked from ifmeorg/ifme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ifmeorg#1713] created ResourceRecommendation class and method
- Loading branch information
1 parent
20a8a14
commit 8dd6ec7
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class ResourceRecommendation | ||
|
||
def initialize(moment) | ||
@moment = moment | ||
end | ||
|
||
def resources | ||
resources = JSON.parse(File.read(Rails.root.join('doc', 'pages', 'resources.json'))) | ||
all_resources = JSON.parse(File.read(Rails.root.join('doc', 'pages', 'resources.json'))) | ||
matched_resources = [] | ||
moment_name = @moment.name.split | ||
all_resources.each do |resource| | ||
unless (resource['tags'] & moment_name).empty? | ||
matched_resources.push(resource) | ||
end | ||
end | ||
matched_resources | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters