Class: Erika::Image

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename: '', full_path: '', index: 0) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
11
12
# File 'lib/erika/image.rb', line 6

def initialize filename: '', full_path: '', index: 0
  @filename, @full_path, @index = filename, full_path, index
  @title                        = filename.sentence_case
  @formatted_index              = '%05d' % index
  @temp_path                    = "#{Erika::Default.temp.image_dir}/#{formatted_index}.jpg"
  _gen_caption_
end

Instance Attribute Details

#captionObject (readonly)

Returns the value of attribute caption.



4
5
6
# File 'lib/erika/image.rb', line 4

def caption
  @caption
end

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/erika/image.rb', line 3

def filename
  @filename
end

#formatted_indexObject (readonly)

Returns the value of attribute formatted_index.



4
5
6
# File 'lib/erika/image.rb', line 4

def formatted_index
  @formatted_index
end

#full_pathObject

Returns the value of attribute full_path.



3
4
5
# File 'lib/erika/image.rb', line 3

def full_path
  @full_path
end

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/erika/image.rb', line 3

def index
  @index
end

#temp_pathObject (readonly)

Returns the value of attribute temp_path.



4
5
6
# File 'lib/erika/image.rb', line 4

def temp_path
  @temp_path
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/erika/image.rb', line 4

def title
  @title
end

#videoObject (readonly)

Returns the value of attribute video.



4
5
6
# File 'lib/erika/image.rb', line 4

def video
  @video
end

Instance Method Details

#create_videoObject



28
29
30
# File 'lib/erika/image.rb', line 28

def create_video
  @video = Erika::Video.new(image: self).save
end

#resize_move_to_tempObject

Chainable method



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/erika/image.rb', line 15

def resize_move_to_temp
  cmd = [
      ['ffmpeg'],
      ['-i', full_path.shell_escape],
      ['-vf', _scaling_params_],
      [@temp_path]
  ].flatten.join(' ')
  
  Erika::Runner.(cmd)
  
  self
end