Class: Hermeneutics::AddrList
- Inherits:
-
Object
- Object
- Hermeneutics::AddrList
- Includes:
- Enumerable
- Defined in:
- lib/hermeneutics/addrs.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(str) ⇒ Object
- #add(mail, real = nil) ⇒ Object
- #add_quoted(str) ⇒ Object
-
#each ⇒ Object
:call-seq: each { |addr| … } -> self.
- #empty? ⇒ Boolean
- #encode ⇒ Object
- #has?(*mails) ⇒ Boolean (also: #has)
- #inspect ⇒ Object
- #notempty? ⇒ Boolean
- #push(addrs) ⇒ Object (also: #<<)
- #quote ⇒ Object
- #to_s ⇒ Object
- #under_domain(*args) ⇒ Object
Class Method Details
Instance Method Details
#==(str) ⇒ Object
650 651 652 |
# File 'lib/hermeneutics/addrs.rb', line 650 def == str @list.find { |a| a == str } end |
#add(mail, real = nil) ⇒ Object
654 655 656 657 658 659 660 |
# File 'lib/hermeneutics/addrs.rb', line 654 def add mail, real = nil if real or not Addr === mail then mail = Addr.create mail, real end @list.push mail self end |
#add_quoted(str) ⇒ Object
662 663 664 665 666 667 |
# File 'lib/hermeneutics/addrs.rb', line 662 def add_quoted str Addr.parse str.to_s do |a,| @list.push a end self end |
#each ⇒ Object
:call-seq:
each { |addr| ... } -> self
Call block for each address.
617 618 619 |
# File 'lib/hermeneutics/addrs.rb', line 617 def each @list.each { |a| yield a } end |
#empty? ⇒ Boolean
578 |
# File 'lib/hermeneutics/addrs.rb', line 578 def empty? ; @list.empty? ; end |
#encode ⇒ Object
603 604 605 606 607 608 609 610 |
# File 'lib/hermeneutics/addrs.rb', line 603 def encode r = [] @list.map { |a| if r.last then r.last << "," end r.push a.encode.dup } r end |
#has?(*mails) ⇒ Boolean Also known as: has
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'lib/hermeneutics/addrs.rb', line 622 def has? *mails mails.flatten! mails.find { |m| case m when Regexp then @list.find { |a| if a.plain =~ m then yield *$~.captures if block_given? true end } else self == m end } end |
#inspect ⇒ Object
591 592 593 |
# File 'lib/hermeneutics/addrs.rb', line 591 def inspect "<#{self.class}: " + (@list.map { |a| a.inspect }.join ", ") + ">" end |
#notempty? ⇒ Boolean
579 |
# File 'lib/hermeneutics/addrs.rb', line 579 def notempty? ; self if @list.notempty? ; end |
#push(addrs) ⇒ Object Also known as: <<
581 582 583 584 585 586 587 588 |
# File 'lib/hermeneutics/addrs.rb', line 581 def push addrs case addrs when nil then when String then add_quoted addrs when Addr then @list.push addrs else addrs.each { |a| push a } end end |
#quote ⇒ Object
599 600 601 |
# File 'lib/hermeneutics/addrs.rb', line 599 def quote @list.map { |a| a.quote }.join ", " end |
#to_s ⇒ Object
595 596 597 |
# File 'lib/hermeneutics/addrs.rb', line 595 def to_s @list.map { |a| a.to_s }.join ", " end |
#under_domain(*args) ⇒ Object
640 641 642 643 644 645 646 647 648 |
# File 'lib/hermeneutics/addrs.rb', line 640 def under_domain *args @list.each { |a| a.plain =~ /(.*)@/ or next l, d = $1, $' case d when *args then yield l end } end |