Class: HaravanTheme::Filters::CommandInput

Inherits:
Object
  • Object
show all
Defined in:
lib/haravan_theme/filters/command_input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#patternsObject (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