Class: Rmsgen::Polnote

Inherits:
Object
  • Object
show all
Defined in:
lib/rmsgen/polnote.rb

Constant Summary collapse

URGENT_SUBJECT =
'Subject: Urgent note'
POLNOTE_TEMPLATE =
File.join(File.dirname(__FILE__), '..', 'templates', 'polnote.erb')
URGENT_TEMPLATE =
File.join(File.dirname(__FILE__), '..', 'templates', 'urgent.erb')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Polnote

Returns a new instance of Polnote.



10
11
12
13
14
15
# File 'lib/rmsgen/polnote.rb', line 10

def initialize(attributes={})
  @body   = attributes[:body]
  @urgent = sanitize_urgent_attribute(attributes[:urgent]) || (@body && @body.include?(URGENT_SUBJECT))
  @id     = attributes[:id]
  compress!
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/rmsgen/polnote.rb', line 3

def body
  @body
end

#expires_onObject

Returns the value of attribute expires_on.



3
4
5
# File 'lib/rmsgen/polnote.rb', line 3

def expires_on
  @expires_on
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/rmsgen/polnote.rb', line 3

def id
  @id
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/rmsgen/polnote.rb', line 3

def title
  @title
end

Instance Method Details

#gsub!(x, y) ⇒ Object



33
34
35
# File 'lib/rmsgen/polnote.rb', line 33

def gsub!(x, y)
  @body.gsub!(x, y)
end

#include?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rmsgen/polnote.rb', line 29

def include?(pattern)
  @body.include?(pattern)
end

#inquireObject



25
26
27
# File 'lib/rmsgen/polnote.rb', line 25

def inquire
  @body = Inquirer.new(self).body
end

#partsObject



49
50
51
# File 'lib/rmsgen/polnote.rb', line 49

def parts
  PartGroup.new(@body)
end

#split(x) ⇒ Object



37
38
39
# File 'lib/rmsgen/polnote.rb', line 37

def split(x)
  @body.split(x)
end

#titleizeObject



21
22
23
# File 'lib/rmsgen/polnote.rb', line 21

def titleize
  @title = Titleizer.new(self).to_html
end

#to_htmlObject



41
42
43
# File 'lib/rmsgen/polnote.rb', line 41

def to_html
  ERB.new(File.read(POLNOTE_TEMPLATE)).result(binding)
end

#to_urgent_htmlObject



45
46
47
# File 'lib/rmsgen/polnote.rb', line 45

def to_urgent_html
  ERB.new(File.read(URGENT_TEMPLATE)).result(binding)
end

#urgent?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rmsgen/polnote.rb', line 17

def urgent?
  @urgent
end