Class: Mediainfo::Stream
- Inherits:
-
Object
- Object
- Mediainfo::Stream
- Defined in:
- lib/mediainfo.rb
Direct Known Subclasses
AudioStream, GeneralStream, ImageStream, MenuStream, TextStream, VideoStream
Defined Under Namespace
Classes: InvalidStreamType
Instance Attribute Summary collapse
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
Class Method Summary collapse
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(stream_type) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(stream_type) ⇒ Stream
Returns a new instance of Stream.
186 187 188 189 190 191 192 193 194 195 |
# File 'lib/mediainfo.rb', line 186 def initialize(stream_type) raise ArgumentError, "need a stream_type, received #{stream_type.inspect}" if stream_type.nil? @stream_type = stream_type.downcase.to_sym # TODO @parsed_response is not the best name anymore, but I'm leaving it # alone to focus on refactoring the interface to the streams # before I refactor the attribute reader implementations. @parsed_response = { @stream_type => {} } end |
Instance Attribute Details
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
197 198 199 |
# File 'lib/mediainfo.rb', line 197 def parsed_response @parsed_response end |
Class Method Details
.create(stream_type) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/mediainfo.rb', line 174 def self.create(stream_type) raise ArgumentError, "need a stream_type, received #{stream_type.inspect}" if stream_type.nil? stream_class_name = "#{stream_type}Stream" if Mediainfo.const_defined?(stream_class_name) Mediainfo.const_get(stream_class_name).new(stream_type) else raise InvalidStreamType, "bad stream type: #{stream_type.inspect}" end end |
.inherited(stream_type) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/mediainfo.rb', line 159 def self.inherited(stream_type) stream_type.extend(AttrReaders) def stream_type.method_added(method_name) if stream_type = name[/[^:]+$/][/^(#{SECTIONS.map { |x| x.to_s.capitalize } * '|'})/] stream_type.downcase! stream_type = stream_type.to_sym else raise "could not determine stream type, please report bug!" end Mediainfo.delegate(method_name, stream_type) end end |
Instance Method Details
#[](k) ⇒ Object
199 |
# File 'lib/mediainfo.rb', line 199 def [](k); @parsed_response[@stream_type][k]; end |
#[]=(k, v) ⇒ Object
200 |
# File 'lib/mediainfo.rb', line 200 def []=(k,v); @parsed_response[@stream_type][k] = v; end |