Class: Odnoklassniki::REST::Mediatopic::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/odnoklassniki/rest/mediatopic/content.rb

Constant Summary collapse

/youtu\.?be|vimeo/.freeze
/soundcloud|snd\.cc/.freeze
/#{VIDEO_LINK_PATTERN}|#{AUDIO_LINK_PATTERN}/.freeze
TEXT_TYPE =
'text'.freeze
'link'.freeze
PHOTO_TYPE =
'photo'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Content

Options: text: string with message to OK (default: ”) images: Array of File (default: []) account_type: :group/:personal (default: :personal)



18
19
20
# File 'lib/odnoklassniki/rest/mediatopic/content.rb', line 18

def initialize(options={})
  @options = Odnoklassniki::Utils._symbolize_kyes(options)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



12
13
14
# File 'lib/odnoklassniki/rest/mediatopic/content.rb', line 12

def options
  @options
end

Instance Method Details

#imagesObject



34
35
36
# File 'lib/odnoklassniki/rest/mediatopic/content.rb', line 34

def images
  @images ||= [uploaded_images].compact
end


29
30
31
32
# File 'lib/odnoklassniki/rest/mediatopic/content.rb', line 29

def link
  @link ||= \
    external_url.blank? ? nil : {type: LINK_TYPE, url: external_url}
end

#messageObject



22
23
24
25
26
27
# File 'lib/odnoklassniki/rest/mediatopic/content.rb', line 22

def message
  @message ||= {
    type: TEXT_TYPE,
    text: (text || '')
  }
end