Class: Locomotivecms::Freight::Post

Inherits:
Squares::Base
  • Object
show all
Defined in:
lib/locomotivecms/freight/post.rb

Constant Summary collapse

IMPORTABLE_PROPERTIES =
[
  :title, :keywords, :posted_at, :body, :teaser, :source, :_visible
]

Instance Method Summary collapse

Instance Method Details

#cms_paramsObject



27
28
29
30
31
32
33
# File 'lib/locomotivecms/freight/post.rb', line 27

def cms_params
  IMPORTABLE_PROPERTIES.reduce({}) do |params, property|
    params.tap do |p|
      p[property] = self.send property
    end
  end
end

#image_urlsObject



21
22
23
24
25
# File 'lib/locomotivecms/freight/post.rb', line 21

def image_urls
  body.scan(/^\[img-\d+\]:.*$/).map do |img_url|
    img_url.chomp.gsub(/^\[img-\d+\]:\s?/, '').gsub(/\s".*$/, '')
  end
end


15
16
17
18
19
# File 'lib/locomotivecms/freight/post.rb', line 15

def links
  body.scan(/^\[\d+\]\:.*$/).map do |link|
    link.chomp.gsub(/^\[.*?\]:\s?/, '')
  end
end