Class: Text::Gen::Filter::Base
- Inherits:
-
Object
- Object
- Text::Gen::Filter::Base
show all
- Defined in:
- lib/text/gen/filter/base.rb
Overview
Base class for all filters Provides common utilities and template method pattern
Direct Known Subclasses
Capitalize, Censor, Clear, Distinct, Downcase, Exclude, Locale, Match, Meta, Pluralize, Reject, Remember, Replace, Select, Swap, Titleize, Upcase
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(filter, depth) ⇒ Base
Returns a new instance of Base.
9
10
11
12
|
# File 'lib/text/gen/filter/base.rb', line 9
def initialize(filter, depth)
@filter = filter
@depth = depth
end
|
Class Method Details
.filter_key ⇒ Object
46
47
48
|
# File 'lib/text/gen/filter/base.rb', line 46
def filter_key
filter_name.downcase
end
|
.filter_name ⇒ Object
42
43
44
|
# File 'lib/text/gen/filter/base.rb', line 42
def filter_name
@filter_name ||= name.split("::").last
end
|
Instance Method Details
#component_key ⇒ Object
14
15
16
|
# File 'lib/text/gen/filter/base.rb', line 14
def component_key
"fn(#{to_s})"
end
|
#key ⇒ Object
19
20
21
22
23
|
# File 'lib/text/gen/filter/base.rb', line 19
def key
return @key if defined?(@key)
@key = @filter["key"].nil? || @filter["key"].empty? ? nil : @filter["key"]
end
|
#to_s ⇒ Object
35
36
37
38
39
|
# File 'lib/text/gen/filter/base.rb', line 35
def to_s
return "#{ type }:#{ key }:#{ value }" if value
return "#{ type }:#{ key }" if key
type
end
|
#type ⇒ Object
31
32
33
|
# File 'lib/text/gen/filter/base.rb', line 31
def type
@type ||= @filter["type"]
end
|
#value ⇒ Object
25
26
27
28
29
|
# File 'lib/text/gen/filter/base.rb', line 25
def value
return @value if defined?(@value)
@value = @filter["value"].nil? || @filter["value"].empty? ? nil : @filter["value"]
end
|