Class: FrameReader
- Inherits:
-
Object
- Object
- FrameReader
- Includes:
- Enumerable
- Defined in:
- lib/terminal_player/spotiphy.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(channels, sample_type, frames_count, frames_ptr) ⇒ FrameReader
constructor
A new instance of FrameReader.
Constructor Details
#initialize(channels, sample_type, frames_count, frames_ptr) ⇒ FrameReader
Returns a new instance of FrameReader.
17 18 19 20 21 22 |
# File 'lib/terminal_player/spotiphy.rb', line 17 def initialize(channels, sample_type, frames_count, frames_ptr) @channels = channels @sample_type = sample_type @size = frames_count * @channels @pointer = FFI::Pointer.new(@sample_type, frames_ptr) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
24 25 26 |
# File 'lib/terminal_player/spotiphy.rb', line 24 def size @size end |
Instance Method Details
#each ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/terminal_player/spotiphy.rb', line 26 def each return enum_for(__method__) unless block_given? ffi_read = :"read_#{@sample_type}" (0...size).each do |index| yield @pointer[index].public_send(ffi_read) end end |