Class: Weasyl::MediaItem

Inherits:
Object
  • Object
show all
Defined in:
lib/weasyl/media.rb

Overview

Base class for media items

Author:

  • Maxine Michalski

Since:

  • 0.1.0

Direct Known Subclasses

Cover, MediaFile, Thumbnail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ MediaItem

Shared initializer for all Media items

Author:

  • Maxine Michalski

Since:

  • 0.1.0



86
87
88
89
90
91
92
93
# File 'lib/weasyl/media.rb', line 86

def initialize(item)
  @id = item[:mediaid]
  @url = URI.parse(item[:url])
  return if item[:links].nil?
  @links = item[:links].map do |k, v|
    Weasyl::Link.new(k, v)
  end
end

Instance Attribute Details

#idInteger (readonly)

Returns Media ID of this item.

Returns:

  • (Integer)

    Media ID of this item

Since:

  • 0.1.0



74
75
76
# File 'lib/weasyl/media.rb', line 74

def id
  @id
end

Returns Links to other media.

Returns:

Since:

  • 0.1.0



81
82
83
# File 'lib/weasyl/media.rb', line 81

def links
  @links
end

#urlURI (readonly)

Returns Media URL to thumbnail.

Returns:

  • (URI)

    Media URL to thumbnail

Since:

  • 0.1.0



77
78
79
# File 'lib/weasyl/media.rb', line 77

def url
  @url
end

Instance Method Details

#id?Boolean

Indicator of if this MediaItem has an ID or not

Returns:

  • (Boolean)

Author:

  • Maxine Michalski

Since:

  • 0.1.0



99
100
101
# File 'lib/weasyl/media.rb', line 99

def id?
  !@id.nil?
end

#links?Boolean

Indicator of if this MediaItem object has links or not

Returns:

  • (Boolean)

Author:

  • Maxine Michalski

Since:

  • 0.1.0



107
108
109
# File 'lib/weasyl/media.rb', line 107

def links?
  !@links.nil?
end