Class: Filter
- Inherits:
-
Object
- Object
- Filter
- Defined in:
- lib/filters/uri.rb,
lib/filters/email.rb,
lib/filters/filter.rb,
lib/filters/markup.rb,
lib/filters/phrase.rb,
lib/filters/version.rb,
lib/filters/profanity.rb
Defined Under Namespace
Classes: Email, Markup, Phrase, Profanity, URI
Constant Summary collapse
- VERSION =
'1.1.1'
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Input string.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Auto generate Filter::Subclass() methods which act as a shortcut to Filter::Subclass.new(…).filter.
- .Profanity(*args) ⇒ Object
- .Profanity!(*args) ⇒ Object
Instance Method Summary collapse
-
#filter ⇒ Object
Non-mutative filter.
-
#initialize(string, options = {}) ⇒ Filter
constructor
Initialize with string and options.
Constructor Details
#initialize(string, options = {}) ⇒ Filter
Initialize with string and options.
12 13 14 |
# File 'lib/filters/filter.rb', line 12 def initialize string, = {} @string, @options = string, end |
Instance Attribute Details
#string ⇒ Object (readonly)
Input string.
7 8 9 |
# File 'lib/filters/filter.rb', line 7 def string @string end |
Class Method Details
.inherited(subclass) ⇒ Object
Auto generate Filter::Subclass() methods which act as a shortcut to Filter::Subclass.new(…).filter
27 28 29 30 31 32 33 34 |
# File 'lib/filters/filter.rb', line 27 def self.inherited subclass (class << self; self end).send :define_method, subclass.name.split('::').last do |*args| subclass.new(*args).filter end (class << self; self end).send :define_method, subclass.name.split('::').last + '!' do |*args| subclass.new(*args).filter! end end |
Instance Method Details
#filter ⇒ Object
Non-mutative filter.
19 20 21 |
# File 'lib/filters/filter.rb', line 19 def filter @string = string.dup and filter! end |