Class: Towsta::Kinds::GalleryKind

Inherits:
MainKind
  • Object
show all
Defined in:
lib/towsta/kinds/gallery.rb

Instance Attribute Summary

Attributes inherited from MainKind

#content

Instance Method Summary collapse

Methods inherited from MainKind

#compare, #compare_parameterized, #get, #initialize, #kind

Constructor Details

This class inherits a constructor from Towsta::Kinds::MainKind

Instance Method Details

#exportObject



17
18
19
20
# File 'lib/towsta/kinds/gallery.rb', line 17

def export
  return '' if @content.class == Array && @content.empty?
  "[#{@content.join ','}]"
end

#set(content) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/towsta/kinds/gallery.rb', line 6

def set content
  return @content = content if content.class == Array
  begin
    gal = JSON.parse(content, :symbolize_names => true)
    @content = []
    gal.each {|g| @content << Bresson::ImageReference.new(g)}
  rescue
    @content = []
  end
end