Class: DiasporaFederation::Entities::Embed

Inherits:
DiasporaFederation::Entity show all
Defined in:
lib/diaspora_federation/entities/embed.rb

Overview

This entity is used to specify embed information about an URL that should be embedded.

Constant Summary

Constants inherited from DiasporaFederation::Entity

DiasporaFederation::Entity::ENTITY_NAME_REGEX, DiasporaFederation::Entity::INVALID_XML_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiasporaFederation::Entity

class_name, entity_class, entity_name, from_hash, from_json, from_xml, #initialize, #to_h, #to_json, #to_xml

Methods included from PropertiesDSL

#class_props, #default_values, #entity, #missing_props, #optional_props, #property, #resolv_aliases

Methods included from Logging

included

Constructor Details

This class inherits a constructor from DiasporaFederation::Entity

Instance Attribute Details

#descriptionString (readonly)

The description of the embedded URL.

Returns:

  • (String)

    description



22
# File 'lib/diaspora_federation/entities/embed.rb', line 22

property :description, :string, optional: true

#imageString (readonly)

The image of the embedded URL.

Returns:

  • (String)

    image



27
# File 'lib/diaspora_federation/entities/embed.rb', line 27

property :image, :string, optional: true

#nothingString (readonly)

True, if nothing should be embedded.

Returns:

  • (String)

    nothing



32
# File 'lib/diaspora_federation/entities/embed.rb', line 32

property :nothing, :boolean, optional: true

#titleString (readonly)

The title of the embedded URL.

Returns:

  • (String)

    title



17
# File 'lib/diaspora_federation/entities/embed.rb', line 17

property :title, :string, optional: true

#urlString (readonly)

URL that should be embedded.

Returns:

  • (String)

    url



12
# File 'lib/diaspora_federation/entities/embed.rb', line 12

property :url, :string, optional: true

Instance Method Details

#to_sString

Returns string representation of this object.

Returns:

  • (String)

    string representation of this object



35
36
37
# File 'lib/diaspora_federation/entities/embed.rb', line 35

def to_s
  "Embed#{":#{url}" if url}"
end

#validateObject

Raises:



39
40
41
42
43
# File 'lib/diaspora_federation/entities/embed.rb', line 39

def validate
  super

  raise ValidationError, "Either 'url' must be set or 'nothing' must be 'true'" unless nothing ^ url
end