Sha256: 219f70d0a1c9261c1c4d530f13722e4dfda85a4800214fcf4e13f54e920e131d
Contents?: true
Size: 827 Bytes
Versions: 1
Compression:
Stored size: 827 Bytes
Contents
module Maildown class Md attr_accessor :string # responses is an array of hashes containing a body: and :content_type def initialize(responses) @responses = responses.reject {|r| r[:content_type] == Mime[:html].to_s || r[:content_type] == Mime[:text].to_s } md_response = responses.detect {|r| r[:content_type] == Mime[:md].to_s } if md_response.present? @string = md_response[:body] @responses.delete(md_response) end end def to_text string end def to_html Maildown::MarkdownEngine.to_html(string) end def to_responses [ { body: to_text, content_type: "text/plain"}, { body: to_html, content_type: "text/html"} ].concat(@responses) end def contains_md? string.present? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
maildown-2.0.0 | lib/maildown/md.rb |