Class: DurableHuggingfaceHub::Types::Organization

Inherits:
Struct
  • Object
show all
Includes:
Loadable
Defined in:
lib/durable_huggingface_hub/types/user.rb

Overview

Information about a HuggingFace Hub organization.

Examples:

Creating an Organization from API response

org = Organization.from_hash({
  "name" => "huggingface",
  "fullname" => "Hugging Face",
  "isEnterprise" => true
})

Accessing organization information

org.name        # => "huggingface"
org.fullname    # => "Hugging Face"
org.enterprise? # => true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#avatar_urlString? (readonly)

Returns Organization avatar URL.

Returns:

  • (String, nil)

    Organization avatar URL



138
# File 'lib/durable_huggingface_hub/types/user.rb', line 138

attribute :avatar_url, Types::OptionalString.default(nil)

#fullnameString? (readonly)

Returns Full display name.

Returns:

  • (String, nil)

    Full display name



134
# File 'lib/durable_huggingface_hub/types/user.rb', line 134

attribute :fullname, Types::OptionalString.default(nil)

#is_enterpriseBoolean? (readonly)

Returns Whether this is an Enterprise organization.

Returns:

  • (Boolean, nil)

    Whether this is an Enterprise organization



142
# File 'lib/durable_huggingface_hub/types/user.rb', line 142

attribute :is_enterprise, Types::OptionalBool.default(nil)

#nameString (readonly)

Returns Organization name/ID.

Returns:

  • (String)

    Organization name/ID



130
# File 'lib/durable_huggingface_hub/types/user.rb', line 130

attribute :name, Types::String

Class Method Details

.from_hash(data) ⇒ Object

Transform isEnterprise from API to is_enterprise



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/durable_huggingface_hub/types/user.rb', line 145

def self.from_hash(data)
  transformed = data.dup
  if transformed.key?("isEnterprise") && !transformed.key?("is_enterprise")
    transformed["is_enterprise"] = transformed.delete("isEnterprise")
  elsif transformed.key?(:isEnterprise) && !transformed.key?(:is_enterprise)
    transformed[:is_enterprise] = transformed.delete(:isEnterprise)
  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

  new(transformed)
end

Instance Method Details

#display_nameString

Returns the display name (fullname if available, otherwise name).

Returns:

  • (String)

    Display name



172
173
174
# File 'lib/durable_huggingface_hub/types/user.rb', line 172

def display_name
  fullname || name
end

#enterprise?Boolean

Checks if this is an Enterprise organization.

Returns:

  • (Boolean)

    True if Enterprise



165
166
167
# File 'lib/durable_huggingface_hub/types/user.rb', line 165

def enterprise?
  is_enterprise == true
end

#inspectString

Returns a detailed inspection string.

Returns:

  • (String)

    Inspection string



186
187
188
189
# File 'lib/durable_huggingface_hub/types/user.rb', line 186

def inspect
  "#<#{self.class.name} name=#{name.inspect} fullname=#{fullname.inspect} " \
    "enterprise=#{enterprise?}>"
end

#to_sString

Returns a short description of the organization.

Returns:

  • (String)

    Description string



179
180
181
# File 'lib/durable_huggingface_hub/types/user.rb', line 179

def to_s
  display_name
end