Class: ADN::Recipes::BroadcastMessageBuilder
- Inherits:
-
Object
- Object
- ADN::Recipes::BroadcastMessageBuilder
- Defined in:
- lib/adn/recipes/broadcast_message_builder.rb
Instance Attribute Summary collapse
-
#attachment ⇒ Object
Returns the value of attribute attachment.
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
-
#headline ⇒ Object
Returns the value of attribute headline.
-
#parse_links ⇒ Object
Returns the value of attribute parse_links.
-
#parse_markdown_links ⇒ Object
Returns the value of attribute parse_markdown_links.
-
#photo ⇒ Object
Returns the value of attribute photo.
-
#read_more_link ⇒ Object
Returns the value of attribute read_more_link.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #annotations ⇒ Object
-
#initialize(params = {}) {|_self| ... } ⇒ BroadcastMessageBuilder
constructor
A new instance of BroadcastMessageBuilder.
- #message ⇒ Object
- #send ⇒ Object
Constructor Details
#initialize(params = {}) {|_self| ... } ⇒ BroadcastMessageBuilder
Returns a new instance of BroadcastMessageBuilder.
9 10 11 12 13 14 15 16 17 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 9 def initialize(params = {}) if params.respond_to? :each_pair params.each_pair do |k, v| send("#{k}=", v) if respond_to?("#{k}=") end end yield self if block_given? end |
Instance Attribute Details
#attachment ⇒ Object
Returns the value of attribute attachment.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def @attachment end |
#channel_id ⇒ Object
Returns the value of attribute channel_id.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def channel_id @channel_id end |
#headline ⇒ Object
Returns the value of attribute headline.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def headline @headline end |
#parse_links ⇒ Object
Returns the value of attribute parse_links.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def parse_links @parse_links end |
#parse_markdown_links ⇒ Object
Returns the value of attribute parse_markdown_links.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def parse_markdown_links @parse_markdown_links end |
#photo ⇒ Object
Returns the value of attribute photo.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def photo @photo end |
#read_more_link ⇒ Object
Returns the value of attribute read_more_link.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def read_more_link @read_more_link end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 6 def text @text end |
Instance Method Details
#annotations ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 19 def annotations annotations = [ { type: 'net.app.core.broadcast.message.metadata', value: { subject: self.headline } } ] if self.read_more_link annotations << { type: 'net.app.core.crosspost', value: { canonical_url: self.read_more_link } } end if self.photo file = ADN::File.upload_file(self.photo, { type: 'net.app.adnrb.upload' }) annotations << { type: 'net.app.core.oembed', value: { "+net.app.core.file" => { file_id: file.id, file_token: file.file_token, format: 'oembed', } } } end if self. file = ADN::File.upload_file(self., { type: 'net.app.adnrb.upload' }) annotations << { type: 'net.app.core.attachments', value: { "+net.app.core.file_list" => [ { file_id: file.id, file_token: file.file_token, format: 'metadata', } ] } } end annotations end |
#message ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/adn/recipes/broadcast_message_builder.rb', line 78 def = { annotations: self.annotations, entities: { parse_links: !!(self.parse_links or self.parse_markdown_links), parse_markdown_links: !!self.parse_markdown_links } } if self.text [:text] = self.text else [:machine_only] = true end end |