Class: Kentaa::Api::Resources::News

Inherits:
Resource show all
Defined in:
lib/kentaa/api/resources/news.rb

Instance Attribute Summary

Attributes inherited from Resource

#id

Attributes inherited from Base

#config, #endpoint_path, #options, #resource_class

Instance Method Summary collapse

Methods inherited from Resource

#create, #created_at, #delete, #initialize, #load, #save, #updated_at

Methods inherited from Base

attribute_key, #initialize, #load, #loaded?

Constructor Details

This class inherits a constructor from Kentaa::Api::Resources::Resource

Instance Method Details

#contentObject



25
26
27
# File 'lib/kentaa/api/resources/news.rb', line 25

def content
  data[:content]
end

#labelsObject



29
30
31
# File 'lib/kentaa/api/resources/news.rb', line 29

def labels
  data[:labels]
end

#object_keyObject



9
10
11
# File 'lib/kentaa/api/resources/news.rb', line 9

def object_key
  "News_#{id}"
end

#photosObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kentaa/api/resources/news.rb', line 41

def photos
  @photos ||= begin
    photos = []

    if data[:photos]
      data[:photos].each do |photo|
        photos << Kentaa::Api::Resources::Photo.new(photo)
      end
    end

    photos
  end
end

#public_idObject



13
14
15
# File 'lib/kentaa/api/resources/news.rb', line 13

def public_id
  data[:public_id]
end

#publish_atObject



37
38
39
# File 'lib/kentaa/api/resources/news.rb', line 37

def publish_at
  Time.parse(data[:publish_at]) if data[:publish_at]
end

#publish_stateObject



33
34
35
# File 'lib/kentaa/api/resources/news.rb', line 33

def publish_state
  data[:publish_state]
end

#siteObject



17
18
19
# File 'lib/kentaa/api/resources/news.rb', line 17

def site
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end

#titleObject



21
22
23
# File 'lib/kentaa/api/resources/news.rb', line 21

def title
  data[:title]
end

#videosObject



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/kentaa/api/resources/news.rb', line 55

def videos
  @videos ||= begin
    videos = []

    if data[:videos]
      data[:videos].each do |video|
        videos << Kentaa::Api::Resources::Video.new(video)
      end
    end

    videos
  end
end