Class: DurableHuggingfaceHub::Types::User
- Includes:
- Loadable
- Defined in:
- lib/durable_huggingface_hub/types/user.rb
Overview
Information about a HuggingFace Hub user.
Instance Attribute Summary collapse
-
#auth ⇒ Hash?
readonly
Authentication information including token details.
-
#avatar_url ⇒ String?
readonly
Avatar image URL.
-
#email ⇒ String?
readonly
Email address.
-
#fullname ⇒ String?
readonly
Full display name.
-
#id ⇒ String?
readonly
User ID.
-
#is_pro ⇒ Boolean?
readonly
Whether user has Pro subscription.
-
#name ⇒ String
readonly
Username.
-
#orgs ⇒ Array<Hash>?
readonly
Organizations the user belongs to.
-
#type ⇒ String?
readonly
User type (e.g., “user”).
Class Method Summary collapse
-
.from_hash(data) ⇒ Object
Transform isPro from API to is_pro.
Instance Method Summary collapse
-
#display_name ⇒ String
Returns the display name (fullname if available, otherwise username).
-
#inspect ⇒ String
Returns a detailed inspection string.
-
#pro? ⇒ Boolean
Checks if the user has a Pro subscription.
-
#to_s ⇒ String
Returns a short description of the user.
Instance Attribute Details
#auth ⇒ Hash? (readonly)
Returns Authentication information including token details.
58 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 58 attribute :auth, Types::Hash.optional.default(nil) |
#avatar_url ⇒ String? (readonly)
Returns Avatar image URL.
46 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 46 attribute :avatar_url, Types::OptionalString.default(nil) |
#email ⇒ String? (readonly)
Returns Email address.
42 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 42 attribute :email, Types::OptionalString.default(nil) |
#fullname ⇒ String? (readonly)
Returns Full display name.
38 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 38 attribute :fullname, Types::OptionalString.default(nil) |
#id ⇒ String? (readonly)
Returns User ID.
30 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 30 attribute :id, Types::OptionalString.default(nil) |
#is_pro ⇒ Boolean? (readonly)
Returns Whether user has Pro subscription.
50 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 50 attribute :is_pro, Types::OptionalBool.default(nil) |
#name ⇒ String (readonly)
Returns Username.
34 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 34 attribute :name, Types::String |
#orgs ⇒ Array<Hash>? (readonly)
Returns Organizations the user belongs to.
54 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 54 attribute :orgs, Types::Array.of(Types::Hash).optional.default(nil) |
#type ⇒ String? (readonly)
Returns User type (e.g., “user”).
26 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 26 attribute :type, Types::OptionalString.default(nil) |
Class Method Details
.from_hash(data) ⇒ Object
Transform isPro from API to is_pro
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 61 def self.from_hash(data) transformed = data.dup if transformed.key?("isPro") && !transformed.key?("is_pro") transformed["is_pro"] = transformed.delete("isPro") elsif transformed.key?(:isPro) && !transformed.key?(:is_pro) transformed[:is_pro] = transformed.delete(:isPro) end if transformed.key?("avatarUrl") && !transformed.key?("avatar_url") transformed["avatar_url"] = transformed.delete("avatarUrl") elsif transformed.key?(:avatarUrl) && !transformed.key?(:avatar_url) transformed[:avatar_url] = transformed.delete(:avatarUrl) end # Filter out unknown keys to avoid dry-struct errors known_keys = [:type, :name, :fullname, :email, :avatar_url, :is_pro, :orgs, "type", "name", "fullname", "email", "avatar_url", "is_pro", "orgs"] transformed = transformed.select { |k, _| known_keys.include?(k) } new(transformed) end |
Instance Method Details
#display_name ⇒ String
Returns the display name (fullname if available, otherwise username).
93 94 95 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 93 def display_name fullname || name end |
#inspect ⇒ String
Returns a detailed inspection string.
107 108 109 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 107 def inspect "#<#{self.class.name} name=#{name.inspect} fullname=#{fullname.inspect} pro=#{pro?}>" end |
#pro? ⇒ Boolean
Checks if the user has a Pro subscription.
86 87 88 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 86 def pro? is_pro == true end |
#to_s ⇒ String
Returns a short description of the user.
100 101 102 |
# File 'lib/durable_huggingface_hub/types/user.rb', line 100 def to_s display_name end |