Class: Woody::Decorators::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/woody/decorators/video.rb

Instance Method Summary collapse

Methods inherited from Base

#method_missing

Constructor Details

#initialize(model, config, creator_model = nil) ⇒ Video

Returns a new instance of Video.



14
15
16
17
18
# File 'lib/woody/decorators/video.rb', line 14

def initialize(model, config, creator_model = nil)
  @config        = config
  @creator_model = creator_model
  super(model)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Woody::Decorators::Base

Instance Method Details

#aspect_ratioObject



20
21
22
23
24
25
# File 'lib/woody/decorators/video.rb', line 20

def aspect_ratio
  @aspect_ratio ||= Helper::AspectRatio.new(
    @model.current_version.height,
    @model.current_version.width
  ).class_name
end

#brandObject



27
28
29
30
31
32
# File 'lib/woody/decorators/video.rb', line 27

def brand
  @brand ||= Woody::Decorators::Brand.new(
    Wes::Data::API::Brand.find(:id, brief.brand_id),
    @config
  )
end

#briefObject



34
35
36
37
38
39
# File 'lib/woody/decorators/video.rb', line 34

def brief
  @brief ||= Woody::Decorators::Brief.new(
    Wes::Data::API::Brief.find(:id, submission.brief_id),
    @config
  )
end

#creatorObject



41
42
43
44
45
# File 'lib/woody/decorators/video.rb', line 41

def creator
  @creator ||= @creator_model ? @creator_model : Wes::Data::API::CreatorUser.find(
    :id, submission.user_id
  )
end

#error?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
# File 'lib/woody/decorators/video.rb', line 47

def error?
  @model.attributes.transcoding_states.map do |transcoding_state|
    if transcoding_state['state'] == "error"
      return true
    end
  end

  false
end

#gifObject



57
58
59
60
61
62
63
# File 'lib/woody/decorators/video.rb', line 57

def gif
  return 'https://i.imgur.com/jZCPUYx.gif' if dev?
  return processing_image unless states?('gif')
  video_transcoding_state('gif').path(
    filename_hash, nil, processing_image
  )
end

#processed?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
70
# File 'lib/woody/decorators/video.rb', line 65

def processed?
  return false if error?
  return true if dev?
  return false unless states?('gif') && states?('mp4')
  type_processed?('gif') && type_processed?('mp4')
end

#thumbnailObject



72
73
74
75
76
77
78
79
# File 'lib/woody/decorators/video.rb', line 72

def thumbnail
  return 'https://public.live.vidsy.co/shared/upload-failed.jpg' if error?
  return 'https://i.imgur.com/jZCPUYx.gif' if dev?
  return processing_image unless states?('gif')
  video_transcoding_state('gif').path(
    filename_hash, 'thumbnail', processing_image
  )
end

#urlObject



81
82
83
84
85
# File 'lib/woody/decorators/video.rb', line 81

def url
  return dev_url if dev?
  return '' unless states?('mp4')
  video_transcoding_state('mp4').path(filename_hash)
end