Class: Feedx::Format::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/feedx/format/abstract.rb

Direct Known Subclasses

JSON, Protobuf

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Abstract

Returns a new instance of Abstract.



2
3
4
# File 'lib/feedx/format/abstract.rb', line 2

def initialize(io)
  @io = io
end

Instance Method Details

#decode(_klass) ⇒ Object



18
19
20
# File 'lib/feedx/format/abstract.rb', line 18

def decode(_klass, **)
  raise 'Not implemented'
end

#decode_each(klass, **opts) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/feedx/format/abstract.rb', line 10

def decode_each(klass, **opts)
  if block_given?
    yield decode(klass, **opts) until eof?
  else
    Enumerator.new {|y| y << decode(klass, **opts) until eof? }
  end
end

#encode(_msg) ⇒ Object



22
23
24
# File 'lib/feedx/format/abstract.rb', line 22

def encode(_msg, **)
  raise 'Not implemented'
end

#eof?Boolean

Returns:



6
7
8
# File 'lib/feedx/format/abstract.rb', line 6

def eof?
  @io.eof?
end