Class: HaravanTheme::Filters::CommandInput
- Inherits:
-
Object
- Object
- HaravanTheme::Filters::CommandInput
- Defined in:
- lib/haravan_theme/filters/command_input.rb
Instance Attribute Summary collapse
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
Instance Method Summary collapse
-
#initialize(inputs = []) ⇒ CommandInput
constructor
A new instance of CommandInput.
- #select(list) ⇒ Object
Constructor Details
#initialize(inputs = []) ⇒ CommandInput
Returns a new instance of CommandInput.
5 6 7 |
# File 'lib/haravan_theme/filters/command_input.rb', line 5 def initialize(inputs=[]) @patterns = inputs.map { |i| Regexp.compile(i) } end |
Instance Attribute Details
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
4 5 6 |
# File 'lib/haravan_theme/filters/command_input.rb', line 4 def patterns @patterns end |
Instance Method Details
#select(list) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/haravan_theme/filters/command_input.rb', line 9 def select(list) return list if patterns.empty? list.select { |entry| patterns.any? { |pat| pat.match(entry) } } end |