Class: Weasyl::Link
- Inherits:
-
Object
- Object
- Weasyl::Link
- Defined in:
- lib/weasyl/media.rb
Overview
A relationship between MediaItems
Instance Attribute Summary collapse
-
#links ⇒ Array<Weasyl::MediaItem>
readonly
Items that are linked to.
-
#type ⇒ Symbol
readonly
Type of item this link links.
Instance Method Summary collapse
-
#initialize(type, link) ⇒ Object
constructor
Initializer for link object.
Constructor Details
#initialize(type, link) ⇒ Object
Initializer for link object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/weasyl/media.rb', line 144 def initialize(type, link) case @type = type when :cover @links = link.map { |l| Weasyl::Cover.new(l) } when :thumbnail @links = link.map { |l| Weasyl::Thumbnail.new(l) } when :submission @links = link.map { |l| Weasyl::MediaFile.new(l) } else raise ArgumentError, "Unknown type: #{@type}" end end |
Instance Attribute Details
#links ⇒ Array<Weasyl::MediaItem> (readonly)
Returns Items that are linked to.
138 139 140 |
# File 'lib/weasyl/media.rb', line 138 def links @links end |
#type ⇒ Symbol (readonly)
Returns Type of item this link links.
135 136 137 |
# File 'lib/weasyl/media.rb', line 135 def type @type end |