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, #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
22
23
24
|
# File 'lib/wp_api_client/entities/post.rb', line 22
def content
post["content"]["rendered"]
end
|
#date ⇒ Object
18
19
20
|
# File 'lib/wp_api_client/entities/post.rb', line 18
def date
Time.parse(post["date_gmt"]) if post["date_gmt"]
end
|
#excerpt ⇒ Object
26
27
28
|
# File 'lib/wp_api_client/entities/post.rb', line 26
def excerpt
post["excerpt"]["rendered"]
end
|
#id ⇒ Object
30
31
32
|
# File 'lib/wp_api_client/entities/post.rb', line 30
def id
post["id"]
end
|
38
39
40
41
42
43
44
45
46
|
# File 'lib/wp_api_client/entities/post.rb', line 38
def meta(key = nil)
@meta ||= relations("https://api.w.org/meta")
if key
@meta[key.to_s]
else
@meta
end
end
|
#slug ⇒ Object
14
15
16
|
# File 'lib/wp_api_client/entities/post.rb', line 14
def slug
post["slug"]
end
|
#terms(taxonomy = nil) ⇒ Object
34
35
36
|
# File 'lib/wp_api_client/entities/post.rb', line 34
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
|