Class: WpApiClient::Entities::Post
- Inherits:
-
Base
- Object
- Base
- WpApiClient::Entities::Post
show all
- Defined in:
- lib/wp_api_client/entities/post.rb
Instance Attribute Summary
Attributes inherited from Base
#resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
build, #initialize, #links, #method_missing, #relations
Class Method Details
.represents?(json) ⇒ Boolean
6
7
8
|
# File 'lib/wp_api_client/entities/post.rb', line 6
def self.represents?(json)
json.dig("_links", "about") and json["_links"]["about"].first["href"] =~ /wp\/v2\/types/
end
|
Instance Method Details
#content ⇒ Object
18
19
20
|
# File 'lib/wp_api_client/entities/post.rb', line 18
def content
post["content"]["rendered"]
end
|
#date ⇒ Object
14
15
16
|
# File 'lib/wp_api_client/entities/post.rb', line 14
def date
Time.parse(post["date_gmt"]) if post["date_gmt"]
end
|
#excerpt ⇒ Object
22
23
24
|
# File 'lib/wp_api_client/entities/post.rb', line 22
def excerpt
post["excerpt"]["rendered"]
end
|
30
31
32
33
34
35
36
37
38
|
# File 'lib/wp_api_client/entities/post.rb', line 30
def meta(key = nil)
@meta ||= relations("https://api.w.org/meta")
if key
@meta[key.to_s]
else
@meta
end
end
|
#terms(taxonomy = nil) ⇒ Object
26
27
28
|
# File 'lib/wp_api_client/entities/post.rb', line 26
def terms(taxonomy = nil)
relations("https://api.w.org/term", taxonomy)
end
|
#title ⇒ Object
10
11
12
|
# File 'lib/wp_api_client/entities/post.rb', line 10
def title
post["title"]["rendered"]
end
|