Class: X::Community
- Extended by:
- Finders
- Defined in:
- x-objects/lib/x/objects/community.rb
Overview
A community of users who post to one another
Constant Summary collapse
- FIELDS =
Every public community field
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[access created_at description id join_policy member_count name].freeze
Instance Attribute Summary collapse
-
#access ⇒ String?
readonly
Who can see the community's posts, as the API names it.
-
#created_at ⇒ Time?
readonly
The creation time.
-
#description ⇒ String?
readonly
The description.
-
#join_policy ⇒ String?
readonly
How users become members, as the API names it.
-
#member_count ⇒ Integer?
readonly
The number of members.
-
#name ⇒ String?
readonly
The name.
Class Method Summary collapse
-
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every community field.
-
.search(query, client:, **params) ⇒ Cursor
Search communities.
Instance Method Summary collapse
-
#permalink ⇒ String
The permalink of the community.
-
#uri ⇒ URI::Generic
The permalink of the community as a URI.
Constructor Details
This class inherits a constructor from X::Resource
Instance Attribute Details
#access ⇒ String? (readonly)
Who can see the community's posts, as the API names it
104 |
# File 'x-objects/lib/x/objects/community.rb', line 104 attribute :access |
#created_at ⇒ Time? (readonly)
The creation time
88 |
# File 'x-objects/lib/x/objects/community.rb', line 88 attribute :created_at, :time |
#description ⇒ String? (readonly)
The description
80 |
# File 'x-objects/lib/x/objects/community.rb', line 80 attribute :description |
#join_policy ⇒ String? (readonly)
How users become members, as the API names it
112 |
# File 'x-objects/lib/x/objects/community.rb', line 112 attribute :join_policy |
#member_count ⇒ Integer? (readonly)
The number of members
96 |
# File 'x-objects/lib/x/objects/community.rb', line 96 attribute :member_count, :integer |
#name ⇒ String? (readonly)
The name
72 |
# File 'x-objects/lib/x/objects/community.rb', line 72 attribute :name |
Class Method Details
.default_params ⇒ Hash{String => Array<String>}
The default query parameters requesting every community field
49 |
# File 'x-objects/lib/x/objects/community.rb', line 49 def default_params = {"community.fields" => FIELDS} |
.search(query, client:, **params) ⇒ Cursor
Search communities
60 61 62 63 |
# File 'x-objects/lib/x/objects/community.rb', line 60 def search(query, client:, **params) Cursor.__send__(:build, self, "communities/search", client:, params: {query:, max_results: MAX_RESULTS}.merge(params), token_param: "next_token", min_results: 10) end |
Instance Method Details
#permalink ⇒ String
The permalink of the community
120 |
# File 'x-objects/lib/x/objects/community.rb', line 120 def permalink = "https://x.com/i/communities/#{id}" |
#uri ⇒ URI::Generic
The permalink of the community as a URI
128 |
# File 'x-objects/lib/x/objects/community.rb', line 128 def uri = URI(permalink) |