Class: Vidibus::Encoder::Util::Input
- Inherits:
-
Object
- Object
- Vidibus::Encoder::Util::Input
- Defined in:
- lib/vidibus/encoder/util/input.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#aspect ⇒ Object
Return aspect ratio of input file.
-
#initialize(options) ⇒ Input
constructor
Initialize an input object.
-
#readable? ⇒ Boolean
Return true if path is readable.
-
#to_s ⇒ Object
Return the path.
-
#validate ⇒ Object
Ensure that a path is given and readable.
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() @path = [: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
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/vidibus/encoder/util/input.rb', line 6 def path @path end |
#properties ⇒ Object (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
#aspect ⇒ Object
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.
24 25 26 |
# File 'lib/vidibus/encoder/util/input.rb', line 24 def readable? File.readable?(path) end |
#to_s ⇒ Object
Return the path.
19 20 21 |
# File 'lib/vidibus/encoder/util/input.rb', line 19 def to_s path end |
#validate ⇒ Object
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 |