Class: Rmsgen::Polnote
- Inherits:
-
Object
- Object
- Rmsgen::Polnote
- 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
-
#body ⇒ Object
Returns the value of attribute body.
-
#expires_on ⇒ Object
Returns the value of attribute expires_on.
-
#id ⇒ Object
Returns the value of attribute id.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #gsub!(x, y) ⇒ Object
- #include?(pattern) ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Polnote
constructor
A new instance of Polnote.
- #inquire ⇒ Object
- #parts ⇒ Object
- #split(x) ⇒ Object
- #titleize ⇒ Object
- #to_html ⇒ Object
- #to_urgent_html ⇒ Object
- #urgent? ⇒ Boolean
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
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/rmsgen/polnote.rb', line 3 def body @body end |
#expires_on ⇒ Object
Returns the value of attribute expires_on.
3 4 5 |
# File 'lib/rmsgen/polnote.rb', line 3 def expires_on @expires_on end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/rmsgen/polnote.rb', line 3 def id @id end |
#title ⇒ Object
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
29 30 31 |
# File 'lib/rmsgen/polnote.rb', line 29 def include?(pattern) @body.include?(pattern) end |
#inquire ⇒ Object
25 26 27 |
# File 'lib/rmsgen/polnote.rb', line 25 def inquire @body = Inquirer.new(self).body end |
#parts ⇒ Object
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 |
#titleize ⇒ Object
21 22 23 |
# File 'lib/rmsgen/polnote.rb', line 21 def titleize @title = Titleizer.new(self).to_html end |
#to_html ⇒ Object
41 42 43 |
# File 'lib/rmsgen/polnote.rb', line 41 def to_html ERB.new(File.read(POLNOTE_TEMPLATE)).result(binding) end |
#to_urgent_html ⇒ Object
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
17 18 19 |
# File 'lib/rmsgen/polnote.rb', line 17 def urgent? @urgent end |