Class: Mail::KeywordsField

Inherits:
StructuredField show all
Defined in:
lib/mail/fields/keywords_field.rb

Constant Summary collapse

FIELD_NAME =
'keywords'
CAPITALIZED_FIELD =
'Keywords'

Instance Method Summary collapse

Methods included from Utilities

included

Methods included from CommonField

included

Constructor Details

#initialize(*args) ⇒ KeywordsField

Returns a new instance of KeywordsField.



10
11
12
13
14
# File 'lib/mail/fields/keywords_field.rb', line 10

def initialize(*args)
  super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
  self.parse
  self
end

Instance Method Details

#decodedObject



34
35
36
# File 'lib/mail/fields/keywords_field.rb', line 34

def decoded
  keywords.join(', ')
end

#defaultObject



38
39
40
# File 'lib/mail/fields/keywords_field.rb', line 38

def default
  keywords
end

#encodedObject



30
31
32
# File 'lib/mail/fields/keywords_field.rb', line 30

def encoded
  "#{CAPITALIZED_FIELD}: #{keywords.join(', ')}\r\n"
end

#keywordsObject



26
27
28
# File 'lib/mail/fields/keywords_field.rb', line 26

def keywords
  phrase_list.phrases
end

#parse(val = value) ⇒ Object



16
17
18
19
20
# File 'lib/mail/fields/keywords_field.rb', line 16

def parse(val = value)
  unless val.blank?
    @phrase_list ||= PhraseList.new(value)
  end
end

#phrase_listObject



22
23
24
# File 'lib/mail/fields/keywords_field.rb', line 22

def phrase_list
  @phrase_list ||= PhraseList.new(value)
end