Class: WordpressClient::Post
- Inherits:
-
Object
- Object
- WordpressClient::Post
- Defined in:
- lib/wordpress_client/post.rb
Overview
Represents a post in Wordpress.
Instance Attribute Summary collapse
-
#categories ⇒ Array[Category]
The Categories the post belongs to.
-
#category_ids ⇒ Object
Returns the value of attribute category_ids.
-
#content_html ⇒ Object
Returns the value of attribute content_html.
-
#date ⇒ Time?
The date of the post, in UTC if available.
-
#excerpt_html ⇒ Object
Returns the value of attribute excerpt_html.
-
#featured_media ⇒ Media?
The featured image, as an instance of Media.
-
#featured_media_id ⇒ Object
Returns the value of attribute featured_media_id.
-
#guid ⇒ String
The permalink/GUID of the post for internal addressing.
-
#id ⇒ Object
Returns the value of attribute id.
-
#meta ⇒ Hash<String,String>
Returns the Post meta, as a
Hash
of String => String. -
#slug ⇒ Object
Returns the value of attribute slug.
-
#status ⇒ "publish", ...
The current status of the post, or
nil
if undetermined. -
#tag_ids ⇒ Object
Returns the value of attribute tag_ids.
-
#tags ⇒ Array[Tag]
The Tags the post belongs to.
-
#title_html ⇒ String
The title of the media, HTML escaped.
-
#updated_at ⇒ Time?
The modification date of the post, in UTC if available.
-
#url ⇒ String
The URL (link) to the post.
Class Method Summary collapse
- .parse(data) ⇒ Object private
Instance Method Summary collapse
-
#featured_image ⇒ Object
Returns the featured media, if the featured media is an image.
-
#initialize(id: nil, slug: nil, url: nil, guid: nil, status: "unknown", title_html: nil, excerpt_html: nil, content_html: nil, updated_at: nil, date: nil, categories: [], tags: [], category_ids: [], tag_ids: [], featured_media: nil, meta: {}) ⇒ Post
constructor
Construct a new instance with the given attributes.
Constructor Details
#initialize(id: nil, slug: nil, url: nil, guid: nil, status: "unknown", title_html: nil, excerpt_html: nil, content_html: nil, updated_at: nil, date: nil, categories: [], tags: [], category_ids: [], tag_ids: [], featured_media: nil, meta: {}) ⇒ Post
Construct a new instance with the given attributes.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/wordpress_client/post.rb', line 66 def initialize( id: nil, slug: nil, url: nil, guid: nil, status: "unknown", title_html: nil, excerpt_html: nil, content_html: nil, updated_at: nil, date: nil, categories: [], tags: [], category_ids: [], tag_ids: [], featured_media: nil, meta: {} ) @id = id @slug = slug @url = url @guid = guid @status = status @title_html = title_html @excerpt_html = excerpt_html @content_html = content_html @updated_at = updated_at @date = date @categories = categories @tags = @category_ids = category_ids @tag_ids = tag_ids @featured_media = featured_media @meta = end |
Instance Attribute Details
#categories ⇒ Array[Category]
Returns the Categories the post belongs to.
38 39 40 |
# File 'lib/wordpress_client/post.rb', line 38 def categories @categories end |
#category_ids ⇒ Object
Returns the value of attribute category_ids.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def category_ids @category_ids end |
#content_html ⇒ Object
Returns the value of attribute content_html.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def content_html @content_html end |
#date ⇒ Time?
Returns the date of the post, in UTC if available.
21 22 23 |
# File 'lib/wordpress_client/post.rb', line 21 def date @date end |
#excerpt_html ⇒ Object
Returns the value of attribute excerpt_html.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def excerpt_html @excerpt_html end |
#featured_media ⇒ Media?
Returns the featured image, as an instance of Media.
46 47 48 |
# File 'lib/wordpress_client/post.rb', line 46 def featured_media @featured_media end |
#featured_media_id ⇒ Object
Returns the value of attribute featured_media_id.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def featured_media_id @featured_media_id end |
#guid ⇒ String
Returns the permalink/GUID of the post for internal addressing.
27 28 29 |
# File 'lib/wordpress_client/post.rb', line 27 def guid @guid end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def id @id end |
#meta ⇒ Hash<String,String>
Returns the Post meta, as a Hash
of String => String.
50 51 52 |
# File 'lib/wordpress_client/post.rb', line 50 def @meta end |
#slug ⇒ Object
Returns the value of attribute slug.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def slug @slug end |
#status ⇒ "publish", ...
Returns the current status of the post, or nil
if undetermined.
34 35 36 |
# File 'lib/wordpress_client/post.rb', line 34 def status @status end |
#tag_ids ⇒ Object
Returns the value of attribute tag_ids.
8 9 10 |
# File 'lib/wordpress_client/post.rb', line 8 def tag_ids @tag_ids end |
#tags ⇒ Array[Tag]
Returns the Tags the post belongs to.
42 43 44 |
# File 'lib/wordpress_client/post.rb', line 42 def @tags end |
#title_html ⇒ String
Returns the title of the media, HTML escaped.
16 17 18 |
# File 'lib/wordpress_client/post.rb', line 16 def title_html @title_html end |
#updated_at ⇒ Time?
Returns the modification date of the post, in UTC if available.
24 25 26 |
# File 'lib/wordpress_client/post.rb', line 24 def updated_at @updated_at end |
#url ⇒ String
Returns the URL (link) to the post.
31 32 33 |
# File 'lib/wordpress_client/post.rb', line 31 def url @url end |
Class Method Details
.parse(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/wordpress_client/post.rb', line 61 def self.parse(data) PostParser.parse(data) end |
Instance Method Details
#featured_image ⇒ Object
Returns the featured media, if the featured media is an image.
103 104 105 106 107 |
# File 'lib/wordpress_client/post.rb', line 103 def featured_image if featured_media featured_media.as_image end end |