Class: Lazylead::PlainCC
- Inherits:
-
Object
- Object
- Lazylead::PlainCC
- 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
- #cc ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(text, regxp = /[^\s]@[^\s]/) ⇒ PlainCC
constructor
The regexp expression for email notification is very simple, here is the reason why bit.ly/38iLKeo.
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
#cc ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/lazylead/cc.rb', line 82 def cc @cc ||= if @text.include? "," @text.split(",").map(&:strip).select { |e| e[@regxp] } elsif @text[@regxp] [@text.strip] end end |
#each(&block) ⇒ Object
90 91 92 |
# File 'lib/lazylead/cc.rb', line 90 def each(&block) cc.each(&block) end |