Module: Paf::Formattable
- Included in:
- Paf
- Defined in:
- lib/paf/formattable.rb
Overview
Processing to format a PAF entry
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#format ⇒ Object
Formats a Paf instance into an array of strings.
-
#to_s ⇒ Object
Formats a Paf instance into a string.
Instance Method Details
#format ⇒ Object
Formats a Paf instance into an array of strings
41 42 43 44 45 46 47 |
# File 'lib/paf/formattable.rb', line 41 def format array = lines %i[post_town postcode].each do |attr| array << send(attr) unless send(attr).to_s.empty? end array end |
#to_s ⇒ Object
Formats a Paf instance into a string
50 51 52 53 |
# File 'lib/paf/formattable.rb', line 50 def to_s string = (lines + [post_town.to_s]).reject(&:empty?).join(', ') ([string] + [postcode]).reject(&:empty?).join('. ') end |