Module: WebPurify::Filters
- Included in:
- Client
- Defined in:
- lib/web_purify/methods/filters.rb
Overview
WebPurify::Filters
Handles methods related to determining/filtering profane text
Instance Method Summary collapse
-
#check(text, options = {}) ⇒ Boolean
Check for existence of profanity.
-
#check_count(text, options = {}) ⇒ Integer
Check for existence of profanity and return number of profane words found.
-
#replace(text, symbol, options = {}) ⇒ String
Replace any matched profanity with provided symbol.
-
#return(text, options = {}) ⇒ Array
Return an array of matched profanity.
Instance Method Details
#check(text, options = {}) ⇒ Boolean
Check for existence of profanity
13 14 15 16 17 18 19 20 |
# File 'lib/web_purify/methods/filters.rb', line 13 def check(text, ={}) params = { :method => WebPurify::Constants.methods[:check], :text => text } parsed = WebPurify::Request.query(@request_base, @query_base, params.merge()) return parsed[:found]=='1' end |
#check_count(text, options = {}) ⇒ Integer
Check for existence of profanity and return number of profane words found
28 29 30 31 32 33 34 35 |
# File 'lib/web_purify/methods/filters.rb', line 28 def check_count(text, ={}) params = { :method => WebPurify::Constants.methods[:check_count], :text => text } parsed = WebPurify::Request.query(@request_base, @query_base, params.merge()) return parsed[:found].to_i end |
#replace(text, symbol, options = {}) ⇒ String
Replace any matched profanity with provided symbol
44 45 46 47 48 49 50 51 52 |
# File 'lib/web_purify/methods/filters.rb', line 44 def replace(text, symbol, ={}) params = { :method => WebPurify::Constants.methods[:replace], :text => text, :replacesymbol => symbol } parsed = WebPurify::Request.query(@request_base, @query_base, params.merge()) return parsed[:text] end |
#return(text, options = {}) ⇒ Array
Return an array of matched profanity
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/web_purify/methods/filters.rb', line 60 def return(text, ={}) params = { :method => WebPurify::Constants.methods[:return], :text => text } parsed = WebPurify::Request.query(@request_base, @query_base, params.merge()) if parsed[:expletive].is_a?(String) return [] << parsed[:expletive] else return parsed.fetch(:expletive, []) end end |