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_encoded(cont) ⇒ Object
- #add_quoted(str) ⇒ Object
-
#each ⇒ Object
:call-seq: each { |addr| … } -> self.
- #encode ⇒ Object
- #has?(*mails) ⇒ Boolean (also: #has)
- #inspect ⇒ Object
- #push(addrs) ⇒ Object
- #quote ⇒ Object
- #to_s ⇒ Object
- #under_domain(*args) ⇒ Object
Class Method Details
.parse(cont) ⇒ Object
581 582 583 |
# File 'lib/hermeneutics/addrs.rb', line 581 def parse cont new.add_encoded cont end |
Instance Method Details
#==(str) ⇒ Object
662 663 664 |
# File 'lib/hermeneutics/addrs.rb', line 662 def == str @list.find { |a| a == str } end |
#add(mail, real = nil) ⇒ Object
666 667 668 669 670 671 672 |
# File 'lib/hermeneutics/addrs.rb', line 666 def add mail, real = nil if real or not Addr === mail then mail = Addr.create mail, real end @list.push mail self end |
#add_encoded(cont) ⇒ Object
681 682 683 684 685 686 |
# File 'lib/hermeneutics/addrs.rb', line 681 def add_encoded cont Addr.parse_decode cont.to_s do |a,| @list.push a end self end |
#add_quoted(str) ⇒ Object
674 675 676 677 678 679 |
# File 'lib/hermeneutics/addrs.rb', line 674 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.
630 631 632 |
# File 'lib/hermeneutics/addrs.rb', line 630 def each @list.each { |a| yield a } end |
#encode ⇒ Object
616 617 618 619 620 621 622 623 |
# File 'lib/hermeneutics/addrs.rb', line 616 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
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/hermeneutics/addrs.rb', line 635 def has? *mails 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
604 605 606 |
# File 'lib/hermeneutics/addrs.rb', line 604 def inspect "<#{self.class}: " + (@list.map { |a| a.inspect }.join ", ") + ">" end |
#push(addrs) ⇒ Object
595 596 597 598 599 600 601 602 |
# File 'lib/hermeneutics/addrs.rb', line 595 def push addrs case addrs when nil then when String then add_encoded addrs when Addr then @list.push addrs else addrs.each { |a| push a } end end |
#quote ⇒ Object
612 613 614 |
# File 'lib/hermeneutics/addrs.rb', line 612 def quote @list.map { |a| a.quote }.join ", " end |
#to_s ⇒ Object
608 609 610 |
# File 'lib/hermeneutics/addrs.rb', line 608 def to_s @list.map { |a| a.to_s }.join ", " end |
#under_domain(*args) ⇒ Object
652 653 654 655 656 657 658 659 660 |
# File 'lib/hermeneutics/addrs.rb', line 652 def under_domain *args @list.each { |a| a.plain =~ /(.*)@/ or next l, d = $1, $' case d when *args then yield l end } end |