Class: Crest::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/crest/card.rb

Overview

An organization's contact card, written as the vCard 3.0 a phone offers to save.

Constant Summary collapse

FOLD =

What a line may hold before a vCard folds it, less the space that continues it.

74

Instance Method Summary collapse

Constructor Details

#initialize(name:, phone:, url: nil, email: nil, org: nil, photo: nil) ⇒ Card

Returns a new instance of Card.

Parameters:

  • name (String)

    organization the card is saved under.

  • phone (String)

    number in the form a phone should dial it.

  • url (String) (defaults to: nil)

    address of the site behind the name.

  • email (String) (defaults to: nil)

    address somebody may write back to.

  • org (String) (defaults to: nil)

    organization the name stands for.

  • photo (String, Pathname) (defaults to: nil)

    image bytes, or the file to read them from.



15
16
17
18
19
20
21
22
# File 'lib/crest/card.rb', line 15

def initialize(name:, phone:, url: nil, email: nil, org: nil, photo: nil)
  @name = name
  @phone = phone
  @url = url
  @email = email
  @org = org
  @photo = photo
end

Instance Method Details

#to_sString

Returns card itself, CRLF-delimited and folded, as the format asks.

Returns:

  • (String)

    card itself, CRLF-delimited and folded, as the format asks.



25
# File 'lib/crest/card.rb', line 25

def to_s = lines.flat_map { |line| fold line }.join("\r\n") << "\r\n"