Class: X::Post
- Extended by:
- BatchFinders, PostCounts, PostSearch, PostWrites, Resources::BatchFinders, Resources::PostCounts, Resources::PostSearch, Resources::PostWrites
- Includes:
- PostCollections, References, Resources::PostCollections, Resources::References
- Defined in:
- x-resources/lib/x/resources/post.rb
Overview
A post, also known as a tweet
Constant Summary collapse
- FIELDS =
Every public post field; the identifiers of referenced resources come with their expansions
The metrics that only the author, or an advertiser, may read, non_public_metrics, organic_metrics, and promoted_metrics, are left out, since a field that depends on who is authenticated would make every request fail for a client that cannot read it, as are the fields of Community Notes and of suggested sources, which the API gives to the programs they belong to. So is source, which the API has deprecated: a field it stops taking would make every request that asks for it fail. Nor does a post read it; a request that names it in its post.fields finds it in Resource#attrs.
A minor release may add to it the fields the API adds, so that a lookup asks for them too; see Resource#hydrated? for what that means for a resource looked up with a list of fields of its own.
%w[article article_title attachments card_uri community_id context_annotations conversation_id created_at display_text_range edit_controls entities geo id lang media_metadata note_post paid_partnership possibly_sensitive public_metrics reply_settings scopes text withheld].freeze
- EXPANSIONS =
The expansions of the resources a post refers to that the object layer resolves
The identifiers of a post's edit history come with every post, so the edit_history_post_ids expansion, which would include each version of the post again, including the post itself, is left out, as is entities.mentions.username, which would include each user the post mentions, since nothing reads them.
A minor release may add to it the expansions the API adds, so that a lookup asks for them too; see Resource#hydrated? for what that means for a resource looked up with a list of expansions of its own.
%w[attachments.media_keys attachments.media_source_tweet attachments.poll_ids author_id geo.place_id in_reply_to_user_id referenced_posts].freeze
Instance Attribute Summary collapse
-
#article ⇒ Hash?
readonly
The article the post publishes, with its title.
-
#article_title ⇒ Hash?
readonly
What the API describes of the title of the article the post publishes.
-
#attachments ⇒ Hash?
readonly
The attachment keys and identifiers.
-
#author_id ⇒ Integer?
readonly
The identifier of the author.
-
#bookmark_count ⇒ Integer?
readonly
The number of bookmarks.
-
#card_uri ⇒ String?
readonly
The URI of the card the post shows.
-
#community_id ⇒ Integer?
readonly
The identifier of the community the post was made in.
-
#context_annotations ⇒ Array<Hash>
readonly
The context annotations.
-
#conversation_id ⇒ Integer?
readonly
The identifier of the first post in the conversation.
-
#coordinates ⇒ Array<Numeric>?
readonly
The longitude and latitude the post was tagged with.
-
#created_at ⇒ Time?
readonly
The time when the post was created.
-
#display_text_range ⇒ Range<Integer>?
readonly
The range of characters of the text the API gives the post that is shown.
-
#edit_controls ⇒ Hash?
readonly
The edit controls.
-
#edit_history_post_ids ⇒ Array<Integer>
(also: #edit_history_tweet_ids)
readonly
The identifiers of every version of the post.
-
#geo ⇒ Hash?
readonly
The tagged place and coordinates.
-
#impression_count ⇒ Integer?
readonly
The number of impressions.
-
#in_reply_to_user_id ⇒ Integer?
readonly
The identifier of the user being replied to.
-
#lang ⇒ String?
readonly
The BCP 47 language tag.
-
#like_count ⇒ Integer?
readonly
The number of likes.
-
#media_metadata ⇒ Array<Hash>
readonly
What the post describes of the media it attaches.
-
#note_post ⇒ Hash?
(also: #note_tweet)
readonly
The full text and entities of a long post.
-
#paid_partnership ⇒ Boolean?
readonly
Whether the post is a paid partnership.
-
#possibly_sensitive ⇒ Boolean?
readonly
Whether the post may contain sensitive content.
-
#public_metrics ⇒ Hash?
readonly
The public metrics.
-
#quote_count ⇒ Integer?
readonly
The number of quotes.
-
#referenced_posts ⇒ Array<Hash>
(also: #referenced_tweets)
readonly
The referenced posts with their types and identifiers.
-
#reply_count ⇒ Integer?
readonly
The number of replies.
-
#reply_settings ⇒ String?
readonly
Who can reply: everyone, mentionedUsers, or following.
-
#repost_count ⇒ Integer?
(also: #retweet_count)
readonly
The number of reposts.
-
#scopes ⇒ Hash?
readonly
Who may see the post.
-
#withheld ⇒ Hash?
readonly
The withholding details.
Class Method Summary collapse
-
.count(query, client:, max_pages: nil, **params) ⇒ Integer
extended
from Resources::PostCounts
Count the recent posts that match a query, without reading them.
-
.count_all(query, client:, max_pages: nil, **params) ⇒ Integer
extended
from Resources::PostCounts
Count the posts from the full archive that match a query, without reading them.
-
.count_all_by_period(query, client:, max_pages: nil, **params) ⇒ Hash{Range<Time> => Integer}
extended
from Resources::PostCounts
Count the posts from the full archive that match a query, by period.
-
.count_by_period(query, client:, max_pages: nil, **params) ⇒ Hash{Range<Time> => Integer}
extended
from Resources::PostCounts
Count the posts from the last seven days that match a query, by period.
-
.create(text = nil, client:, reply_to: nil, quote: nil, media_ids: nil, community: nil, **params) ⇒ Post
extended
from Resources::PostWrites
Create a post as the authenticated user.
-
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every post field and expansion.
-
.delete(post, client:) ⇒ Boolean
extended
from Resources::PostWrites
Delete a post as the authenticated user.
-
.find(id, client:, **params) {|problem| ... } ⇒ Resource?
extended
from Resources::Finders
Look up a resource by identifier.
-
.find!(id, client:, **params) ⇒ Resource
extended
from Resources::Finders
Look up a resource by identifier, which must exist.
-
.find_all(ids, client:, concurrency: DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Resource>
extended
from Resources::BatchFinders
Look up many resources by identifier, in parallel batches.
-
.hide_reply(post, client:) ⇒ Boolean
extended
from Resources::PostWrites
Hide a reply to a post of the authenticated user.
-
.hydrate_all(resources, client:, concurrency: DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Resource>
extended
from Resources::BatchFinders
Replace the resources that are not hydrated with the full resources.
-
.reposts_of_me(client:, **params) ⇒ Cursor
(also: #retweets_of_me)
extended
from Resources::PostSearch
The posts of the authenticated user that other users have reposted.
-
.search(query, client:, **params) ⇒ Cursor
extended
from Resources::PostSearch
Search recent posts.
-
.search_all(query, client:, **params) ⇒ Cursor
extended
from Resources::PostSearch
Search the full archive of posts.
-
.unhide_reply(post, client:) ⇒ Boolean
extended
from Resources::PostWrites
Show a reply that was hidden, as the author of the post it replies to.
Instance Method Summary collapse
-
#author ⇒ User?
The author, resolved from the includes or as a stub holding only its identifier.
-
#community ⇒ Community?
The community the post was made in, as a stub holding only its identifier.
-
#delete ⇒ Boolean
Delete this post as the authenticated user.
-
#entities ⇒ Hash?
The entities found in the full text.
-
#expanded_text ⇒ String?
The text with every shortened link replaced by the URL it stands for.
-
#hide_reply ⇒ Boolean
Hide this reply, as the author of the post it replies to.
-
#in_reply_to_user ⇒ User?
The user being replied to, resolved from the includes or built as a stub.
-
#liked_by(**params) ⇒ Cursor
included
from Resources::PostCollections
The users who liked this post.
-
#matching_rules ⇒ Array<MatchingRule>
The rules of the filtered stream this post matched.
-
#media ⇒ Array<Media>
The attached media, from the includes or as stubs holding only their keys.
-
#media_source_posts ⇒ Array<Post>
(also: #media_source_tweets)
The posts the attached media was first posted with.
-
#paid_partnership? ⇒ Boolean
Check whether the post is a paid partnership.
-
#permalink ⇒ String
The permalink of the post, by the author's username when known.
-
#place ⇒ Place?
The tagged place, from the includes or as a stub holding only its identifier.
-
#polls ⇒ Array<Poll>
The attached polls, from the includes or as stubs holding only their identifiers.
-
#possibly_sensitive? ⇒ Boolean
Check whether the post may contain sensitive content.
-
#quote? ⇒ Boolean
included
from Resources::References
Check whether this post is a quote.
-
#quoted ⇒ Post?
included
from Resources::References
The post this post quotes.
-
#quotes(**params) ⇒ Cursor
(also: #quote_tweets)
included
from Resources::PostCollections
The posts quoting this post.
-
#references ⇒ Array<Post>
included
from Resources::References
The referenced posts, resolved from the includes or built as stubs.
-
#replied_to ⇒ Post?
included
from Resources::References
The post this post replies to.
-
#reply? ⇒ Boolean
included
from Resources::References
Check whether this post is a reply.
-
#repost? ⇒ Boolean
(also: #retweet?)
included
from Resources::References
Check whether this post is a repost.
-
#reposted ⇒ Post?
(also: #retweeted)
included
from Resources::References
The post this post reposts.
-
#reposted_by(**params) ⇒ Cursor
(also: #retweeted_by)
included
from Resources::PostCollections
The users who reposted this post.
-
#reposts(**params) ⇒ Cursor
(also: #retweets)
included
from Resources::PostCollections
The reposts of this post, each a post of its own by the user who reposted it.
-
#text ⇒ String?
The full text.
-
#unhide_reply ⇒ Boolean
Show this reply after hiding it, as the author of the post it replies to.
-
#uri ⇒ URI::Generic
The permalink of the post as a URI.
-
#urls ⇒ Array<Hash>
The links in the full text, each with its shortened url and its expanded_url.
Constructor Details
This class inherits a constructor from X::Resource
Instance Attribute Details
#article ⇒ Hash? (readonly)
The article the post publishes, with its title
246 |
# File 'x-resources/lib/x/resources/post.rb', line 246 attribute :article, :object |
#article_title ⇒ Hash? (readonly)
What the API describes of the title of the article the post publishes
254 |
# File 'x-resources/lib/x/resources/post.rb', line 254 attribute :article_title, :object |
#attachments ⇒ Hash? (readonly)
The attachment keys and identifiers
343 |
# File 'x-resources/lib/x/resources/post.rb', line 343 attribute :attachments, :object |
#author_id ⇒ Integer? (readonly)
The identifier of the author
143 |
# File 'x-resources/lib/x/resources/post.rb', line 143 attribute :author_id, :integer |
#bookmark_count ⇒ Integer? (readonly)
The number of bookmarks
423 |
# File 'x-resources/lib/x/resources/post.rb', line 423 attribute :bookmark_count, :integer, key: %w[public_metrics bookmark_count] |
#card_uri ⇒ String? (readonly)
The URI of the card the post shows
238 |
# File 'x-resources/lib/x/resources/post.rb', line 238 attribute :card_uri |
#community_id ⇒ Integer? (readonly)
The identifier of the community the post was made in
159 |
# File 'x-resources/lib/x/resources/post.rb', line 159 attribute :community_id, :integer |
#context_annotations ⇒ Array<Hash> (readonly)
The context annotations
326 |
# File 'x-resources/lib/x/resources/post.rb', line 326 attribute :context_annotations, :objects |
#conversation_id ⇒ Integer? (readonly)
The identifier of the first post in the conversation
151 |
# File 'x-resources/lib/x/resources/post.rb', line 151 attribute :conversation_id, :integer |
#coordinates ⇒ Array<Numeric>? (readonly)
The longitude and latitude the post was tagged with
351 |
# File 'x-resources/lib/x/resources/post.rb', line 351 attribute :coordinates, key: %w[geo coordinates coordinates] |
#created_at ⇒ Time? (readonly)
The time when the post was created
135 |
# File 'x-resources/lib/x/resources/post.rb', line 135 attribute :created_at, :time |
#display_text_range ⇒ Range<Integer>? (readonly)
The range of characters of the text the API gives the post that is shown
It leaves out the mentions a reply begins with and the link to media it ends with. It is a range of the text the post holds itself, which for a long post is the text cut short, not the full text #text reads.
219 |
# File 'x-resources/lib/x/resources/post.rb', line 219 attribute :display_text_range, :range |
#edit_controls ⇒ Hash? (readonly)
The edit controls
206 |
# File 'x-resources/lib/x/resources/post.rb', line 206 attribute :edit_controls, :object |
#edit_history_post_ids ⇒ Array<Integer> (readonly) Also known as: edit_history_tweet_ids
The identifiers of every version of the post
198 |
# File 'x-resources/lib/x/resources/post.rb', line 198 attribute :edit_history_post_ids, :integers, tweet_key: %w[edit_history_tweet_ids] |
#geo ⇒ Hash? (readonly)
The tagged place and coordinates
359 |
# File 'x-resources/lib/x/resources/post.rb', line 359 attribute :geo, :object |
#impression_count ⇒ Integer? (readonly)
The number of impressions
431 |
# File 'x-resources/lib/x/resources/post.rb', line 431 attribute :impression_count, :integer, key: %w[public_metrics impression_count] |
#in_reply_to_user_id ⇒ Integer? (readonly)
The identifier of the user being replied to
167 |
# File 'x-resources/lib/x/resources/post.rb', line 167 attribute :in_reply_to_user_id, :integer |
#lang ⇒ String? (readonly)
The BCP 47 language tag
127 |
# File 'x-resources/lib/x/resources/post.rb', line 127 attribute :lang |
#like_count ⇒ Integer? (readonly)
The number of likes
407 |
# File 'x-resources/lib/x/resources/post.rb', line 407 attribute :like_count, :integer, key: %w[public_metrics like_count] |
#media_metadata ⇒ Array<Hash> (readonly)
What the post describes of the media it attaches
262 |
# File 'x-resources/lib/x/resources/post.rb', line 262 attribute :media_metadata, :objects |
#note_post ⇒ Hash? (readonly) Also known as: note_tweet
The full text and entities of a long post
375 |
# File 'x-resources/lib/x/resources/post.rb', line 375 attribute :note_post, :object, tweet_key: %w[note_tweet] |
#paid_partnership ⇒ Boolean? (readonly)
Whether the post is a paid partnership
270 |
# File 'x-resources/lib/x/resources/post.rb', line 270 attribute :paid_partnership, :boolean |
#possibly_sensitive ⇒ Boolean? (readonly)
Whether the post may contain sensitive content
175 |
# File 'x-resources/lib/x/resources/post.rb', line 175 attribute :possibly_sensitive, :boolean |
#public_metrics ⇒ Hash? (readonly)
The public metrics
383 |
# File 'x-resources/lib/x/resources/post.rb', line 383 attribute :public_metrics, :object |
#quote_count ⇒ Integer? (readonly)
The number of quotes
415 |
# File 'x-resources/lib/x/resources/post.rb', line 415 attribute :quote_count, :integer, key: %w[public_metrics quote_count] |
#referenced_posts ⇒ Array<Hash> (readonly) Also known as: referenced_tweets
The referenced posts with their types and identifiers
334 |
# File 'x-resources/lib/x/resources/post.rb', line 334 attribute :referenced_posts, :objects, tweet_key: %w[referenced_tweets] |
#reply_count ⇒ Integer? (readonly)
The number of replies
399 |
# File 'x-resources/lib/x/resources/post.rb', line 399 attribute :reply_count, :integer, key: %w[public_metrics reply_count] |
#reply_settings ⇒ String? (readonly)
Who can reply: everyone, mentionedUsers, or following
190 |
# File 'x-resources/lib/x/resources/post.rb', line 190 attribute :reply_settings |
#repost_count ⇒ Integer? (readonly) Also known as: retweet_count
The number of reposts
391 |
# File 'x-resources/lib/x/resources/post.rb', line 391 attribute :repost_count, :integer, key: %w[public_metrics repost_count], tweet_key: %w[public_metrics retweet_count] |
#scopes ⇒ Hash? (readonly)
Who may see the post
A post its author shared with followers alone holds {"followers" => true}.
230 |
# File 'x-resources/lib/x/resources/post.rb', line 230 attribute :scopes, :object |
#withheld ⇒ Hash? (readonly)
The withholding details
367 |
# File 'x-resources/lib/x/resources/post.rb', line 367 attribute :withheld, :object |
Class Method Details
.count(query, client:, max_pages: nil, **params) ⇒ Integer Originally defined in module Resources::PostCounts
Count the recent posts that match a query, without reading them
The recent posts are counted a page of periods at a time, as the full archive is, which max_pages limits.
.count_all(query, client:, max_pages: nil, **params) ⇒ Integer Originally defined in module Resources::PostCounts
Count the posts from the full archive that match a query, without reading them
The archive is counted a page of periods at a time, and the API bills each page, so a count over many years can take many requests, which max_pages limits, raising PageLimitReached rather than read past them.
.count_all_by_period(query, client:, max_pages: nil, **params) ⇒ Hash{Range<Time> => Integer} Originally defined in module Resources::PostCounts
Count the posts from the full archive that match a query, by period
The archive is counted a page of periods at a time, and the API bills each page, so a count over many years can take many requests, which max_pages limits, raising PageLimitReached rather than read past them.
.count_by_period(query, client:, max_pages: nil, **params) ⇒ Hash{Range<Time> => Integer} Originally defined in module Resources::PostCounts
Count the posts from the last seven days that match a query, by period
The recent posts are counted a page of periods at a time, as the full archive is, which max_pages limits.
.create(text = nil, client:, reply_to: nil, quote: nil, media_ids: nil, community: nil, **params) ⇒ Post Originally defined in module Resources::PostWrites
Create a post as the authenticated user
The API bills each post created, and bills a post whose text holds a URL more than ten times as much. A post needs no text when it has something else to show, such as media.
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every post field and expansion
98 99 100 101 |
# File 'x-resources/lib/x/resources/post.rb', line 98 def default_params {"post.fields" => FIELDS, "user.fields" => User::FIELDS, "media.fields" => Media::FIELDS, "poll.fields" => Poll::FIELDS, "place.fields" => Place::FIELDS, "expansions" => EXPANSIONS} end |
.delete(post, client:) ⇒ Boolean Originally defined in module Resources::PostWrites
Delete a post as the authenticated user
.find(id, client:, **params) {|problem| ... } ⇒ Resource? Originally defined in module Resources::Finders
Look up a resource by identifier
.find!(id, client:, **params) ⇒ Resource Originally defined in module Resources::Finders
Look up a resource by identifier, which must exist
The error it raises names the identifier looked up, whether the identifier or a resource was given. Its cause is the X::NotFound of a lookup the API answered with a 404 that reports the resource as not found.
.find_all(ids, client:, concurrency: DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Resource> Originally defined in module Resources::BatchFinders
Look up many resources by identifier, in parallel batches
The resources come back in the order of the identifiers they were asked for by, whatever order the batches were answered in, one for each identifier that was found, so an identifier asked for twice comes back twice, as hydrate_all keeps a resource it is given twice. Each identifier is asked for once, however often it is given.
.hide_reply(post, client:) ⇒ Boolean Originally defined in module Resources::PostWrites
Hide a reply to a post of the authenticated user
X still shows a hidden reply, behind a notice that its author was hidden.
.hydrate_all(resources, client:, concurrency: DEFAULT_CONCURRENCY, **params) {|problem| ... } ⇒ Array<Resource> Originally defined in module Resources::BatchFinders
Replace the resources that are not hydrated with the full resources
A resource that hydrate would look up is looked up, which is a stub and also a resource a response included without every field, so what comes back is hydrated throughout. A resource that was not found is dropped, as is nil, which a reference to no resource reads as, such as the author of a post whose response named none, and a hydrated resource is kept as it is, so resources that are all hydrated need no lookup. What was found is stored in each original, so hydrating one of them afterwards costs no request, unless params override a default field or expansion parameter: what such a lookup found is not the full resource, so it is returned without being stored, and hydrating an original fetches the full resource. A resource that holds what hydrate returns, because hydrate or an earlier hydrate_all stored it, is replaced with that, and looked up again by no request, since the API bills each resource a lookup returns.
.reposts_of_me(client:, **params) ⇒ Cursor Also known as: retweets_of_me Originally defined in module Resources::PostSearch
The posts of the authenticated user that other users have reposted
The endpoint names no user, so these are always the posts of the user the client authenticates as.
.search(query, client:, **params) ⇒ Cursor Originally defined in module Resources::PostSearch
Search recent posts
.search_all(query, client:, **params) ⇒ Cursor Originally defined in module Resources::PostSearch
Search the full archive of posts
A page holds up to 500 posts, or 100 when the request asks for context annotations, as the default fields do.
.unhide_reply(post, client:) ⇒ Boolean Originally defined in module Resources::PostWrites
Show a reply that was hidden, as the author of the post it replies to
Instance Method Details
#author ⇒ User?
The author, resolved from the includes or as a stub holding only its identifier
439 |
# File 'x-resources/lib/x/resources/post.rb', line 439 reference :author, :User, key: %w[author_id] |
#community ⇒ Community?
The community the post was made in, as a stub holding only its identifier
455 |
# File 'x-resources/lib/x/resources/post.rb', line 455 reference :community, :Community, key: %w[community_id] |
#delete ⇒ Boolean
Delete this post as the authenticated user
553 554 555 |
# File 'x-resources/lib/x/resources/post.rb', line 553 def delete self.class.delete(self, client: client!) end |
#entities ⇒ Hash?
The entities found in the full text
The entities, such as links, mentions, and hashtags, come from note_post for a long post, whose note the API gives entities when the full text has any, and from the post itself for a short one, so that each lies where #text holds it. A long post whose note holds none has none: the entities the post holds itself, such as its annotations, lie in the text cut short, which attrs holds.
291 |
# File 'x-resources/lib/x/resources/post.rb', line 291 def entities = Shape.read_object("#{self.class}#entities", full["entities"]) |
#expanded_text ⇒ String?
The text with every shortened link replaced by the URL it stands for
A link the API expanded to no URL is left as it is, and a link without a url, which the API documents as one that may hold none, is passed over, as it holds nothing to replace.
Every link is replaced in one pass over the text, so a URL a link stands for is never read for the links after it, and holds what it holds, even the shortened url of another link of the post. A url that begins another, longer one is not read in it.
The rest of the text is as #text reads it, HTML-escaped as the API sends it, and each URL is HTML-escaped as it is put in, since the API sends a URL as it is, so the whole text is escaped alike: unescape it to display it.
542 543 544 545 |
# File 'x-resources/lib/x/resources/post.rb', line 542 def replacements = expansions Shape.read_string("#{self.class}#expanded_text", text)&.gsub(Regexp.union(replacements.keys.sort_by { |url| -url.length }), replacements) end |
#hide_reply ⇒ Boolean
Hide this reply, as the author of the post it replies to
563 564 565 |
# File 'x-resources/lib/x/resources/post.rb', line 563 def hide_reply self.class.hide_reply(self, client: client!) end |
#in_reply_to_user ⇒ User?
The user being replied to, resolved from the includes or built as a stub
447 |
# File 'x-resources/lib/x/resources/post.rb', line 447 reference :in_reply_to_user, :User, key: %w[in_reply_to_user_id] |
#liked_by(**params) ⇒ Cursor Originally defined in module Resources::PostCollections
The users who liked this post
#matching_rules ⇒ Array<MatchingRule>
The rules of the filtered stream this post matched
A post the filtered stream delivers names the rules it matched, and any other post names none. The streaming client of x-streams builds the posts of a stream given X::Post as its object_class.
313 314 315 316 |
# File 'x-resources/lib/x/resources/post.rb', line 313 def matching_rules reader = "#{self.class}#matching_rules" Shape.objects(reader, attrs["matching_rules"]).map { |rule| Utils.read(reader, rule) { MatchingRule.new(rule) } }.freeze end |
#media ⇒ Array<Media>
The attached media, from the includes or as stubs holding only their keys
471 |
# File 'x-resources/lib/x/resources/post.rb', line 471 references :media, :Media, key: %w[attachments media_keys] |
#media_source_posts ⇒ Array<Post> Also known as: media_source_tweets
The posts the attached media was first posted with
A post that attaches media another post was made with, as one that shares a video does, names that post as the source of the media. Each is read from the includes, or built as a stub holding only its identifier.
491 |
# File 'x-resources/lib/x/resources/post.rb', line 491 references :media_source_posts, :Post, key: %w[attachments media_source_tweet_id] |
#paid_partnership? ⇒ Boolean
Check whether the post is a paid partnership
|
|
# File 'x-resources/lib/x/resources/post.rb', line 272
|
#permalink ⇒ String
The permalink of the post, by the author's username when known
513 |
# File 'x-resources/lib/x/resources/post.rb', line 513 def permalink = "https://x.com/#{Shape.read_string("#{self.class}#permalink", &.username) || "i"}/status/#{id}" |
#place ⇒ Place?
The tagged place, from the includes or as a stub holding only its identifier
463 |
# File 'x-resources/lib/x/resources/post.rb', line 463 reference :place, :Place, key: %w[geo place_id] |
#polls ⇒ Array<Poll>
The attached polls, from the includes or as stubs holding only their identifiers
479 |
# File 'x-resources/lib/x/resources/post.rb', line 479 references :polls, :Poll, key: %w[attachments poll_ids] |
#possibly_sensitive? ⇒ Boolean
Check whether the post may contain sensitive content
|
|
# File 'x-resources/lib/x/resources/post.rb', line 177
|
#quote? ⇒ Boolean Originally defined in module Resources::References
Check whether this post is a quote
#quoted ⇒ Post? Originally defined in module Resources::References
The post this post quotes
#quotes(**params) ⇒ Cursor Also known as: quote_tweets Originally defined in module Resources::PostCollections
The posts quoting this post
#references ⇒ Array<Post> Originally defined in module Resources::References
The referenced posts, resolved from the includes or built as stubs
#replied_to ⇒ Post? Originally defined in module Resources::References
The post this post replies to
#reply? ⇒ Boolean Originally defined in module Resources::References
Check whether this post is a reply
#repost? ⇒ Boolean Also known as: retweet? Originally defined in module Resources::References
Check whether this post is a repost
#reposted ⇒ Post? Also known as: retweeted Originally defined in module Resources::References
The post this post reposts
#reposted_by(**params) ⇒ Cursor Also known as: retweeted_by Originally defined in module Resources::PostCollections
The users who reposted this post
#reposts(**params) ⇒ Cursor Also known as: retweets Originally defined in module Resources::PostCollections
The reposts of this post, each a post of its own by the user who reposted it
#text ⇒ String?
The full text
A long post, of more than 280 characters, holds its full text in note_post, and a text cut short with an ellipsis and a link to the post; this reads the full text.
It is the text as the API sends it, which escapes &, <, and > as &, <, and >, and it stays so throughout 1.x, so unescape it to display it.
119 |
# File 'x-resources/lib/x/resources/post.rb', line 119 def text = full["text"] |
#unhide_reply ⇒ Boolean
Show this reply after hiding it, as the author of the post it replies to
573 574 575 |
# File 'x-resources/lib/x/resources/post.rb', line 573 def unhide_reply self.class.unhide_reply(self, client: client!) end |
#uri ⇒ URI::Generic
The permalink of the post as a URI
522 |
# File 'x-resources/lib/x/resources/post.rb', line 522 def uri = URI(permalink) |
#urls ⇒ Array<Hash>
The links in the full text, each with its shortened url and its expanded_url
300 |
# File 'x-resources/lib/x/resources/post.rb', line 300 def urls = Shape.objects("#{self.class}#urls", entities&.[]("urls")) |