Class: Bake::Format::NDJSON

Inherits:
Object
  • Object
show all
Defined in:
lib/bake/format/ndjson.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ NDJSON



18
19
20
# File 'lib/bake/format/ndjson.rb', line 18

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



22
23
24
# File 'lib/bake/format/ndjson.rb', line 22

def file
  @file
end

Class Method Details

.input(file) ⇒ Object



11
12
13
# File 'lib/bake/format/ndjson.rb', line 11

def self.input(file)
  new(file)
end

.output(file, value) ⇒ Object



15
16
# File 'lib/bake/format/ndjson.rb', line 15

def self.output(file, value)
end

Instance Method Details

#eachObject



24
25
26
27
28
29
30
# File 'lib/bake/format/ndjson.rb', line 24

def each
  return to_enum unless block_given?
  
  @file.each_line do |line|
    yield JSON.parse(line)
  end
end