Class: SlackTransformer::Entities

Inherits:
Object
  • Object
show all
Defined in:
lib/slack_transformer/entities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Entities

Returns a new instance of Entities.



5
6
7
# File 'lib/slack_transformer/entities.rb', line 5

def initialize(input)
  @input = input
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/slack_transformer/entities.rb', line 3

def input
  @input
end

Instance Method Details

#to_slackObject

See api.slack.com/docs/message-formatting#how_to_escape_characters NB: The order matters here. If you were to replace < with &lt; first, for

example, you'd end up with &amp;lt;


12
13
14
15
16
# File 'lib/slack_transformer/entities.rb', line 12

def to_slack
  input.gsub('&', '&amp;')
       .gsub('<', '&lt;')
       .gsub('>', '&gt;')
end