Class: SlackTransformer::Slack
- Inherits:
-
Object
- Object
- SlackTransformer::Slack
- Defined in:
- lib/slack_transformer/slack.rb,
lib/slack_transformer/slack/bold.rb,
lib/slack_transformer/slack/code.rb,
lib/slack_transformer/slack/quote.rb,
lib/slack_transformer/slack/italics.rb,
lib/slack_transformer/slack/blockquote.rb,
lib/slack_transformer/slack/preformatted.rb,
lib/slack_transformer/slack/strikethrough.rb
Defined Under Namespace
Classes: Blockquote, Bold, Code, Italics, Preformatted, Quote, Strikethrough
Constant Summary collapse
- TRANSFORMERS =
[ SlackTransformer::Slack::Bold, SlackTransformer::Slack::Italics, SlackTransformer::Slack::Strikethrough, SlackTransformer::Slack::Code, SlackTransformer::Slack::Preformatted, SlackTransformer::Slack::Quote, SlackTransformer::Slack::Blockquote ]
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(input) ⇒ Slack
constructor
A new instance of Slack.
- #to_html ⇒ Object
Constructor Details
#initialize(input) ⇒ Slack
Returns a new instance of Slack.
23 24 25 |
# File 'lib/slack_transformer/slack.rb', line 23 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
11 12 13 |
# File 'lib/slack_transformer/slack.rb', line 11 def input @input end |
Instance Method Details
#to_html ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/slack_transformer/slack.rb', line 27 def to_html html = TRANSFORMERS.reduce(input) do |html, transformer| transformer.new(html).to_html end "<p>#{html.gsub("\n", '<br>')}</p>" end |