Class: Ducksboard::Image

Inherits:
Widget
  • Object
show all
Defined in:
lib/ducksboard/image.rb

Instance Attribute Summary

Attributes inherited from Widget

#data, #id, #type

Instance Method Summary collapse

Methods inherited from Widget

#save, #update, #valid?, #value, #value=

Constructor Details

#initialize(*args) ⇒ Image

Returns a new instance of Image.



6
7
8
9
# File 'lib/ducksboard/image.rb', line 6

def initialize(*args)
  super
  @data[:value] ||={}
end

Instance Method Details

#captionObject



25
26
27
# File 'lib/ducksboard/image.rb', line 25

def caption
  @data[:value][:caption]
end

#caption=(text = nil) ⇒ Object



29
30
31
# File 'lib/ducksboard/image.rb', line 29

def caption=(text=nil)
  @data[:value][:caption] = caption.to_s
end

#sourceObject



11
12
13
# File 'lib/ducksboard/image.rb', line 11

def source
  @data[:value][:source]
end

#source=(image_location) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ducksboard/image.rb', line 15

def source=(image_location)
  source_value = if image_location =~ /^http/
    image_location
  else
    'data:image/png;base64,' + 
      Base64.encode64(File.read(File.expand_path(image_location)))
  end
  @data[:value][:source] = source_value
end

#timestampObject



33
34
35
# File 'lib/ducksboard/image.rb', line 33

def timestamp
  @data[:timestamp]
end

#timestamp=(time) ⇒ Object



37
38
39
# File 'lib/ducksboard/image.rb', line 37

def timestamp=(time)
  @data[:timestamp] = time
end