Class: MediaInfoNative::StreamProxy
- Inherits:
-
Object
- Object
- MediaInfoNative::StreamProxy
show all
- Defined in:
- lib/mediainfo-native/mediainfo.rb
Constant Summary
collapse
- SingleStreamAPIError =
Class.new(RuntimeError)
- NoStreamsForProxyError =
Class.new(NoMethodError)
- UnknownAttributeError =
Class.new(NoMethodError)
Instance Method Summary
collapse
Constructor Details
#initialize(streams) ⇒ StreamProxy
Returns a new instance of StreamProxy.
38
39
40
|
# File 'lib/mediainfo-native/mediainfo.rb', line 38
def initialize(streams)
@streams = streams
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/mediainfo-native/mediainfo.rb', line 64
def method_missing(m, *a, &b)
case @streams.size
when 0
raise NoStreamsForProxyError
when 1
if @streams.first.respond_to?(m)
@streams.first.send(m, *a, &b)
else
raise UnknownAttributeError
end
else
raise SingleStreamAPIError
end
end
|
Instance Method Details
#[](idx) ⇒ Object
46
|
# File 'lib/mediainfo-native/mediainfo.rb', line 46
def [](idx); @streams[idx]; end
|
#count ⇒ Object
47
|
# File 'lib/mediainfo-native/mediainfo.rb', line 47
def count; @streams.size; end
|
#respond_to?(meth, include_all = false) ⇒ Boolean
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/mediainfo-native/mediainfo.rb', line 49
def respond_to?(meth, include_all = false)
begin
case @streams.size
when 0
false
when 1
@streams.first.respond_to?(meth, include_all)
when [:[], :count].include?(meth)
true
else
raise SingleStreamAPIError
end
end || super
end
|