Module: Card::Set::Abstract::EmailField::EmailTextFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod005-card-mod-email/abstract/email_field.rb,
card/tmpsets/set/mod004-card-mod-email/abstract/email_field.rb

Overview

format :html do def pointer_items args card.item_names(context: :raw).map do |iname| wrap_item iname, args end end end#

Instance Method Summary collapse

Instance Method Details

#email_address?(string) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'card/tmpsets/set/mod005-card-mod-email/abstract/email_field.rb', line 36

def email_address? string
  string =~ /.+\@.+\..+/
end

#email_address_from_card(name, context) ⇒ Object



40
41
42
43
# File 'card/tmpsets/set/mod005-card-mod-email/abstract/email_field.rb', line 40

def email_address_from_card name, context
  card = Card.fetch name
  card.&.email || email_addresses_from_card_content(card, context)
end

#email_addresses(context) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'card/tmpsets/set/mod005-card-mod-email/abstract/email_field.rb', line 25

def email_addresses context
  context ||= self
  card.item_names(context: context.name).map do |name|
    # FIXME: context is processed twice here because pointers absolutize
    # item_names by default while other types can return relative names.
    # That's poor default behavior and should be fixed!
    name = name.to_name.absolute context
    email_address?(name) ? name : email_address_from_card(name, context)
  end.flatten.compact.join(", ")
end

#email_addresses_from_card_content(card, context) ⇒ Object



45
46
47
# File 'card/tmpsets/set/mod005-card-mod-email/abstract/email_field.rb', line 45

def email_addresses_from_card_content card, context
  subformat(card).contextual_content(context).split(/[,\n]/)
end