Class: GrubY::Filters::Filter
- Inherits:
-
Object
- Object
- GrubY::Filters::Filter
- Defined in:
- lib/gruubY/filters.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #call(*args) ⇒ Object
-
#initialize(name = "Filter", &block) ⇒ Filter
constructor
A new instance of Filter.
- #|(other) ⇒ Object
- #~@ ⇒ Object
Constructor Details
#initialize(name = "Filter", &block) ⇒ Filter
Returns a new instance of Filter.
8 9 10 11 |
# File 'lib/gruubY/filters.rb', line 8 def initialize(name = "Filter", &block) @name = name @block = block || proc { true } end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/gruubY/filters.rb', line 6 def name @name end |
Instance Method Details
#&(other) ⇒ Object
17 18 19 |
# File 'lib/gruubY/filters.rb', line 17 def &(other) Filter.new("(#{name}&#{other.name})") { |*args| call(*args) && other.call(*args) } end |
#call(*args) ⇒ Object
13 14 15 |
# File 'lib/gruubY/filters.rb', line 13 def call(*args) @block.call(*args) end |