Class: Flatito::PrintItems
- Inherits:
-
Object
- Object
- Flatito::PrintItems
- Includes:
- RegexFromSearch
- Defined in:
- lib/flatito/print_items.rb
Instance Attribute Summary collapse
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
- #filter_by_search(items) ⇒ Object
-
#initialize(search) ⇒ PrintItems
constructor
A new instance of PrintItems.
- #print(items, pathname = nil) ⇒ Object
- #renderer ⇒ Object
Methods included from RegexFromSearch
Constructor Details
#initialize(search) ⇒ PrintItems
Returns a new instance of PrintItems.
8 9 10 |
# File 'lib/flatito/print_items.rb', line 8 def initialize(search) @search = search end |
Instance Attribute Details
#search ⇒ Object (readonly)
Returns the value of attribute search.
6 7 8 |
# File 'lib/flatito/print_items.rb', line 6 def search @search end |
Instance Method Details
#filter_by_search(items) ⇒ Object
20 21 22 23 24 |
# File 'lib/flatito/print_items.rb', line 20 def filter_by_search(items) items.select do |item| regex.match?(item.key) end end |
#print(items, pathname = nil) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/flatito/print_items.rb', line 12 def print(items, pathname = nil) items = filter_by_search(items) if search return unless items.any? renderer.print_pathname(pathname) if pathname renderer.print_items(items) end |