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

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod012-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)


35
36
37
# File 'platypus/tmp/set/gem-defaults/mod012-email/abstract/email_field.rb', line 35

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

#email_address_from_card(name, context) ⇒ Object



39
40
41
42
# File 'platypus/tmp/set/gem-defaults/mod012-email/abstract/email_field.rb', line 39

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



24
25
26
27
28
29
30
31
32
33
# File 'platypus/tmp/set/gem-defaults/mod012-email/abstract/email_field.rb', line 24

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



44
45
46
# File 'platypus/tmp/set/gem-defaults/mod012-email/abstract/email_field.rb', line 44

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