Class: Sieve::Vacation

Inherits:
Object
  • Object
show all
Defined in:
lib/sieve-parser/vacation.rb

Overview

This class contains the attributes of vacation/autoreplay(action)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Vacation

New object

Parameters:

  • (:subject) (String)

    subject of vacation

  • (:content) (String)

    content of vacation

  • (:days) (Integer)

    days of recurrence message for same From



13
14
15
16
17
18
# File 'lib/sieve-parser/vacation.rb', line 13

def initialize params={}
  @days = (params[:days] ? params[:days].to_i : 1)
  @subject = params[:subject]
  @content = params[:content]
  @type = "vacation"
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/sieve-parser/vacation.rb', line 7

def content
  @content
end

#daysObject

Returns the value of attribute days.



7
8
9
# File 'lib/sieve-parser/vacation.rb', line 7

def days
  @days
end

#subjectObject

Returns the value of attribute subject.



7
8
9
# File 'lib/sieve-parser/vacation.rb', line 7

def subject
  @subject
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/sieve-parser/vacation.rb', line 7

def type
  @type
end

Class Method Details

.parse_text(text) ⇒ Vacation

Parse text and return self with params

Parameters:

  • text (string)

    of vacation action

Returns:



23
24
25
26
# File 'lib/sieve-parser/vacation.rb', line 23

def self.parse_text(text)
  params = text.scan(/vacation :days (\d+) :subject "(.*)".*\n.*\s*(.*)/)[0]
  Vacation.new(:days=>params[0],:subject => params[1],:content => params[2])
end

Instance Method Details

#to_sstring

Return text of vacation action

Returns:

  • (string)

    text of vacation formated



30
31
32
33
34
35
36
37
# File 'lib/sieve-parser/vacation.rb', line 30

def to_s
  %Q{vacation :days #{@days} :subject "#{@subject}" :mime text:
Content-Type: text/html;

#{@content}
.
;}
end