Class: Vidibus::Encoder::Util::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/vidibus/encoder/util/input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Input

Initialize an input object. One option is required:

:path [String] The path to the input file



13
14
15
16
# File 'lib/vidibus/encoder/util/input.rb', line 13

def initialize(options)
  @path = options[:path]
  set_properties!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *arguments) ⇒ Object (private)

Try to return value from properties hash. Return nil if property is undefined or nil.



53
54
55
56
57
58
59
# File 'lib/vidibus/encoder/util/input.rb', line 53

def method_missing(sym, *arguments)
  if properties && value = properties[sym]
    value
  else
    nil
  end
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/vidibus/encoder/util/input.rb', line 6

def path
  @path
end

#propertiesObject (readonly)

Returns the value of attribute properties.



7
8
9
# File 'lib/vidibus/encoder/util/input.rb', line 7

def properties
  @properties
end

Instance Method Details

#aspectObject

Return aspect ratio of input file.



34
35
36
# File 'lib/vidibus/encoder/util/input.rb', line 34

def aspect
  @aspect ||= width/height.to_f
end

#readable?Boolean

Return true if path is readable.

Returns:

  • (Boolean)


24
25
26
# File 'lib/vidibus/encoder/util/input.rb', line 24

def readable?
  File.readable?(path)
end

#to_sObject

Return the path.



19
20
21
# File 'lib/vidibus/encoder/util/input.rb', line 19

def to_s
  path
end

#validateObject

Ensure that a path is given and readable.



29
30
31
# File 'lib/vidibus/encoder/util/input.rb', line 29

def validate
  readable? || raise(InputError, 'Input is not readable')
end