Class: WpApiClient::Entities::Post
Instance Attribute Summary
Attributes inherited from BaseEntity
#resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseEntity
#embedded, #initialize, #links
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.new(post["date_gmt"])
end
|
#id ⇒ Object
22
23
24
|
# File 'lib/wp_api_client/entities/post.rb', line 22
def id
post["id"]
end
|
#terms ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/wp_api_client/entities/post.rb', line 26
def terms
if embedded?
terms = []
embedded["https://api.w.org/term"].map do |taxonomy|
taxonomy.each do |term|
terms << WpApiClient::Entities::Term.new(term, @api)
end
end
terms
end
end
|
#title ⇒ Object
10
11
12
|
# File 'lib/wp_api_client/entities/post.rb', line 10
def title
post["title"]["rendered"]
end
|