Class: AsciiDataTools::Filter::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii-data-tools/filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Filter

Returns a new instance of Filter.



7
8
9
# File 'lib/ascii-data-tools/filter.rb', line 7

def initialize(&block)
  @filter_block = block
end

Instance Method Details

#<<(upstream_filter) ⇒ Object



11
12
13
14
# File 'lib/ascii-data-tools/filter.rb', line 11

def <<(upstream_filter)
  @upstream = upstream_filter
  self
end

#has_records?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ascii-data-tools/filter.rb', line 24

def has_records?
  upstream.has_records?
end

#readObject



16
17
18
# File 'lib/ascii-data-tools/filter.rb', line 16

def read
  filter(upstream.read)
end

#write(output_stream) ⇒ Object



20
21
22
# File 'lib/ascii-data-tools/filter.rb', line 20

def write(output_stream)
  output_stream << read while has_records?
end