Class: CountVonCount::Formatters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/count_von_count/formatter.rb

Direct Known Subclasses

Json, Text, Yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, output = nil) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/count_von_count/formatter.rb', line 9

def initialize(path, output = nil)
  @path = path
  @output_dir = output
end

Instance Attribute Details

#output_dirObject (readonly)

Returns the value of attribute output_dir.



8
9
10
# File 'lib/count_von_count/formatter.rb', line 8

def output_dir
  @output_dir
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/count_von_count/formatter.rb', line 7

def path
  @path
end

Instance Method Details

#write_output(countObj) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/count_von_count/formatter.rb', line 14

def write_output(countObj)
  formatted = serialize(countObj)
  if output_dir
    write_file(formatted)
  else
    write_stdout(formatted)
  end
end