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, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names

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



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

property :description, :string, optional: true

#imageString (readonly)

The image of the embedded URL.

Returns:

  • (String)

    image



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

property :image, :string, optional: true

#nothingString (readonly)

True, if nothing should be embedded.

Returns:

  • (String)

    nothing



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

property :nothing, :boolean, optional: true

#titleString (readonly)

The title of the embedded URL.

Returns:

  • (String)

    title



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

property :title, :string, optional: true

#urlString (readonly)

URL that should be embedded.

Returns:

  • (String)

    url



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

property :url, :string, optional: true

Instance Method Details

#to_sString

Returns string representation of this object

Returns:

  • (String)

    string representation of this object



33
34
35
# File 'lib/diaspora_federation/entities/embed.rb', line 33

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

#validateObject

Raises:



37
38
39
40
41
# File 'lib/diaspora_federation/entities/embed.rb', line 37

def validate
  super

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