class WordpressClient::Term

@abstract Implement a subclass for the resource type.

Implementation for the abstract “term” in Wordpress.

@see Category @see Tag

Attributes

id[R]
name_html[R]
slug[R]

Public Class Methods

new(id:, name_html:, slug:) click to toggle source
# File lib/wordpress_client/term.rb, line 33
def initialize(id:, name_html:, slug:)
  @id = id
  @name_html = name_html
  @slug = slug
end
parse(data) click to toggle source

@api private

Parses a data structure from a WP API response body into this term type.

# File lib/wordpress_client/term.rb, line 25
def self.parse(data)
  new(
    id: data.fetch("id"),
    name_html: data.fetch("name"),
    slug: data.fetch("slug"),
  )
end

Public Instance Methods

==(other) click to toggle source

@api private Compares another instance. All attributes in this list must be equal for the instances to be equal:

  • id

  • name_html

  • slug

One must also not be a subclass of the other; they must be the exact same class.

Calls superclass method
# File lib/wordpress_client/term.rb, line 48
def ==(other)
  if other.is_a? Term
    other.class == self.class &&
      other.id == id &&
      other.name_html == name_html &&
      other.slug == slug
  else
    super
  end
end
inspect() click to toggle source

Shows a nice representation of the term type.

# File lib/wordpress_client/term.rb, line 60
def inspect
  "#<#{self.class} ##{id} #{name_html.inspect} (#{slug})>"
end