class WordpressClient::Media

Represents a media record in Wordpress.

Attributes

date[RW]
description[RW]
guid[RW]
id[RW]
media_details[RW]
media_type[RW]
slug[RW]
source_url[RW]
title_html[RW]
updated_at[RW]

Public Class Methods

new( id: nil, slug: nil, media_type: nil, title_html: nil, description: nil, date: nil, updated_at: nil, guid: nil, link: nil, media_details: {} ) click to toggle source

Creates a new instance, populating the fields with the passed values.

# File lib/wordpress_client/media.rb, line 50
def initialize(
  id: nil,
  slug: nil,
  media_type: nil,
  title_html: nil,
  description: nil,
  date: nil,
  updated_at: nil,
  guid: nil,
  link: nil,
  media_details: {}
)
  @id = id
  @slug = slug
  @media_type = media_type
  @title_html = title_html
  @date = date
  @updated_at = updated_at
  @description = description
  @guid = guid
  @link = link
  @media_details = media_details
end
parse(data) click to toggle source

@api private

# File lib/wordpress_client/media.rb, line 45
def self.parse(data)
  MediaParser.parse(data)
end

Public Instance Methods

as_image() click to toggle source

Returns the same Media instance if it is an image, else nil.

# File lib/wordpress_client/media.rb, line 77
def as_image
  if media_type == "image"
    self
  end
end