Class: Fragile::Plugin::SortFilter
- Inherits:
-
Object
- Object
- Fragile::Plugin::SortFilter
- Defined in:
- lib/fragile/plugin/sort_filter.rb
Overview
Instance Attribute Summary collapse
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize(options = {}) ⇒ SortFilter
constructor
A new instance of SortFilter.
Constructor Details
#initialize(options = {}) ⇒ SortFilter
Returns a new instance of SortFilter.
14 15 16 |
# File 'lib/fragile/plugin/sort_filter.rb', line 14 def initialize(={}) @proc = [:proc] end |
Instance Attribute Details
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
12 13 14 |
# File 'lib/fragile/plugin/sort_filter.rb', line 12 def proc @proc end |
Instance Method Details
#call(data) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/fragile/plugin/sort_filter.rb', line 18 def call(data) if @proc data.sort do |x, y| @proc.call(x, y) end else data end end |