使用 Vpim Gem 创建公司卡
我使用 Vpim 生成 .vcf 文件,然后用户可以将其导入到他们的地址簿中。我遇到的问题是,他们下载的信息是针对公司而不是个人的,因此我需要将卡标记为此类。有没有办法使用 Vpim 来做到这一点,或者我可以使用另一种 gem 来实现这一点?
def to_vcf
card = Vpim::Vcard::Maker.make2 do |maker|
...
end
end
地址簿中的名片来源
BEGIN:VCARD
VERSION:3.0
N:;;;;
FN:The Flow Skatepark
ORG:The Flow Skatepark;
item1.TEL;type=pref:(614) 864-1610
item1.X-ABLabel:Work #
item2.ADR;type=WORK;type=pref:;;4252 Groves Rd;Columbus;OH;43232;USA
item2.X-ABADR:us
BDAY;value=date:2001-07-06
X-ABShowAs:COMPANY
X-ABUID:5F7349CB-369F-4EAC-AB65-49ED902BEF9F\:ABPerson
END:VCARD
地址簿中的非名片来源
BEGIN:VCARD
VERSION:3.0
N:;The Flow Skatepark;;;
FN:The Flow Skatepark
item1.TEL;type=pref:(614) 864-1610
item1.X-ABLabel:Work #
item2.ADR;type=WORK;type=pref:;;4252 Groves Rd;Columbus;OH;43232;USA
item2.X-ABADR:us
BDAY;value=date:2001-07-06
X-ABUID:5F7349CB-369F-4EAC-AB65-49ED902BEF9F\:ABPerson
END:VCARD
显然,这些代码示例有两个主要区别:
- ORG:The Flow Skatepark;
- X-ABSShowAs:COMPANY
但是我不知道这如何转化为 Vpim。
I'm using Vpim to generate .vcf files that users can then import into their address books. The problem that I'm having is that the information that their downloading is for a Company and not a person so I need to mark the card as being such. Is there a way to do this using Vpim or is there another gem that I could use to accomplish this?
def to_vcf
card = Vpim::Vcard::Maker.make2 do |maker|
...
end
end
Source of a Business Card from Address Book
BEGIN:VCARD
VERSION:3.0
N:;;;;
FN:The Flow Skatepark
ORG:The Flow Skatepark;
item1.TEL;type=pref:(614) 864-1610
item1.X-ABLabel:Work #
item2.ADR;type=WORK;type=pref:;;4252 Groves Rd;Columbus;OH;43232;USA
item2.X-ABADR:us
BDAY;value=date:2001-07-06
X-ABShowAs:COMPANY
X-ABUID:5F7349CB-369F-4EAC-AB65-49ED902BEF9F\:ABPerson
END:VCARD
Source of a Non-Business Card from Address Book
BEGIN:VCARD
VERSION:3.0
N:;The Flow Skatepark;;;
FN:The Flow Skatepark
item1.TEL;type=pref:(614) 864-1610
item1.X-ABLabel:Work #
item2.ADR;type=WORK;type=pref:;;4252 Groves Rd;Columbus;OH;43232;USA
item2.X-ABADR:us
BDAY;value=date:2001-07-06
X-ABUID:5F7349CB-369F-4EAC-AB65-49ED902BEF9F\:ABPerson
END:VCARD
Obviously there are two main differences in these code samples:
- ORG:The Flow Skatepark;
- X-ABShowAs:COMPANY
I don't know how this translates into Vpim however.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
快速而肮脏的实施,我希望我正确理解你:
Quick and dirty implementation, I hope that I understood you correctly:
看起来maker对象有一个org=方法,你可以用它来设置ORG。至于X-ABShowAs,maker有一个add_field方法。您可以为此创建自己的字段(http://vpim.rubyforge.org/classes/Vpim/DirectoryInfo/Field.html)。
Looks like the maker object has a org= method, which you can use to set ORG. As for X-ABShowAs, maker has an add_field method. You can probably create your own field (http://vpim.rubyforge.org/classes/Vpim/DirectoryInfo/Field.html) for that.