Module: CatchNotes::ImageSupport

Included in:
Base
Defined in:
lib/catch_notes/module/image_support.rb

Overview

Adds support for working with an image attached to a note.

Instance Method Summary collapse

Instance Method Details

#attached_imageObject

Returns the images attached to the note



12
13
14
15
16
17
18
# File 'lib/catch_notes/module/image_support.rb', line 12

def attached_image
  if attached_image?
    @image ||= Image.new(:url => @attr['media'].first['src'], :note => self)
  else
    nil
  end
end

#attached_image=(image_object_or_file_path_or_url) ⇒ Object

Sets the image attached to the note, and uploads the image.

Parameters

  • image_object_or_file_path_or_url - Can be one of three things: a CatchNotes::Image instance, a path to a file on the local filesystem, or a url to an image. Passing in nil will delete the current attachment.



24
25
26
# File 'lib/catch_notes/module/image_support.rb', line 24

def attached_image=(image_object_or_file_path_or_url)
  
end

#attached_image?Boolean

Returns true if the note has an attached image.

Returns:

  • (Boolean)


7
8
9
# File 'lib/catch_notes/module/image_support.rb', line 7

def attached_image?
  !!((@attr['media'] && @attr['media'].size > 0) || @image)
end