Sha256: 93e6c6b730397b9eacf731b7b441bd1643de8b50e2048109d5cf9c8976bcb79c
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
class Ppl::Format::Contact::Full < Ppl::Format::Contact attr_writer :postal_address_format def initialize @postal_address_format = Ppl::Format::Contact::PostalAddress.new end def process(contact) lines = [] first_line = first_line(contact) if first_line != "" lines.push(first_line) end vitals = vitals(contact) if vitals != "" lines.push("") lines.push(vitals) lines.push("") lines.push("") end if !contact.postal_address.nil? lines.push("Postal Address:") lines.push(@postal_address_format.process(contact)) end return lines.join("\n") end private def first_line(contact) line = "" if !contact.name.nil? line += contact.name end if !contact.email_address.nil? line += " <#{contact.email_address}>" end return line end def vitals(contact) vitals = [] if !contact.birthday.nil? vitals.push(format_vital("Birthday", contact.birthday.strftime("%Y-%m-%d"))) end if !contact.phone_number.nil? vitals.push(format_vital("Telephone", contact.phone_number)) end if !contact.organization.nil? vitals.push(format_vital("Organization", contact.organization)) end return vitals.join("\n") end def format_vital(name, value) return sprintf(" %-12s %s", name, value) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ppl-1.3.0 | lib/ppl/format/contact/full.rb |
ppl-1.2.0 | lib/ppl/format/contact/full.rb |