Class: MailxRuby::CommandGenerator
- Inherits:
-
Object
- Object
- MailxRuby::CommandGenerator
- Defined in:
- lib/mailx_ruby/command_generator.rb
Instance Attribute Summary collapse
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#body ⇒ Object
Returns the value of attribute body.
-
#cc ⇒ Object
Returns the value of attribute cc.
-
#html ⇒ Object
Returns the value of attribute html.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
- #generate ⇒ Object
-
#initialize(attributes) ⇒ CommandGenerator
constructor
A new instance of CommandGenerator.
- #inline_css_body ⇒ Object
- #options_string ⇒ Object
- #subject_with_headers ⇒ Object
Constructor Details
#initialize(attributes) ⇒ CommandGenerator
Returns a new instance of CommandGenerator.
9 10 11 |
# File 'lib/mailx_ruby/command_generator.rb', line 9 def initialize(attributes) assign_attributes attributes end |
Instance Attribute Details
#bcc ⇒ Object
Returns the value of attribute bcc.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def bcc @bcc end |
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def body @body end |
#cc ⇒ Object
Returns the value of attribute cc.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def cc @cc end |
#html ⇒ Object
Returns the value of attribute html.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def html @html end |
#subject ⇒ Object
Returns the value of attribute subject.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def subject @subject end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/mailx_ruby/command_generator.rb', line 3 def to @to end |
Class Method Details
.execute(options) ⇒ Object
5 6 7 |
# File 'lib/mailx_ruby/command_generator.rb', line 5 def self.execute() new().execute end |
Instance Method Details
#execute ⇒ Object
13 14 15 |
# File 'lib/mailx_ruby/command_generator.rb', line 13 def execute `#{generate}` end |
#generate ⇒ Object
31 32 33 34 35 |
# File 'lib/mailx_ruby/command_generator.rb', line 31 def generate "mailx #{} #{stringify(to)} <<-\"EOM\" #{inline_css_body} EOM" end |
#inline_css_body ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/mailx_ruby/command_generator.rb', line 21 def inline_css_body if !html body.text elsif body.has_css? body.to_inline_css else body.to_plain_text end end |
#options_string ⇒ Object
37 38 39 40 41 |
# File 'lib/mailx_ruby/command_generator.rb', line 37 def .map do |key, value| "-#{key} \"#{value}\"" end.join(" ") end |
#subject_with_headers ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/mailx_ruby/command_generator.rb', line 43 def subject_with_headers if html "$(echo \"#{subject}\nContent-Type: text/html\")" else subject end end |