Class: Rounders::Matchers::Filename

Inherits:
Matcher
  • Object
show all
Defined in:
lib/rounders/matchers/filename.rb

Instance Attribute Summary collapse

Attributes inherited from Matcher

#matchers

Instance Method Summary collapse

Methods inherited from Matcher

build, inherited

Methods included from Plugins::Pluggable

included

Constructor Details

#initialize(pattern) ⇒ Filename

Returns a new instance of Filename.



6
7
8
# File 'lib/rounders/matchers/filename.rb', line 6

def initialize(pattern)
  @pattern = pattern
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



4
5
6
# File 'lib/rounders/matchers/filename.rb', line 4

def pattern
  @pattern
end

Instance Method Details

#match(message) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rounders/matchers/filename.rb', line 10

def match(message)
  return if message.attachment?
  matches = message.attachments.map do |attachment|
    match = attachment.filename.match(pattern)
    match.nil? ? nil : attachment
  end
  matches.compact
end