Class: Lazylead::PlainCC

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/lazylead/cc.rb

Overview

Array of CC addresses from text for email notification.

PlainCC.new("[email protected], , -,[email protected]").cc    # ==> ["[email protected]", "[email protected]"]
Author

Yurii Dubinka ([email protected])

Copyright

Copyright © 2019-2020 Yurii Dubinka

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(text, regxp = /[^\s]@[^\s]/) ⇒ PlainCC

The regexp expression for email notification is very simple, here is the reason why bit.ly/38iLKeo



77
78
79
80
# File 'lib/lazylead/cc.rb', line 77

def initialize(text, regxp = /[^\s]@[^\s]/)
  @text = text
  @regxp = regxp
end

Instance Method Details

#ccObject



82
83
84
85
86
87
88
89
90
# File 'lib/lazylead/cc.rb', line 82

def cc
  @cc ||= begin
            if @text.include? ","
              @text.split(",").map(&:strip).select { |e| e[@regxp] }
            elsif @text[@regxp]
              [@text.strip]
            end
          end
end

#each(&block) ⇒ Object



92
93
94
# File 'lib/lazylead/cc.rb', line 92

def each(&block)
  cc.each(&block)
end