Class: FileFormatterOutputData

Inherits:
Object
  • Object
show all
Includes:
Reloadable
Defined in:
lib/file_formatter_output_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatter_input) ⇒ FileFormatterOutputData

Returns a new instance of FileFormatterOutputData.



7
8
9
10
11
12
# File 'lib/file_formatter_output_data.rb', line 7

def initialize(formatter_input)
	@__formatter_input__ = formatter_input
	
	@__format__ = :delimited
	@__delimiter__ = :comma
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/file_formatter_output_data.rb', line 43

def method_missing(sym, *args)
	# If the requested method matches the name of the formatter_input
	# it is returned, i.e. 'presort_run'
	if @__formatter_input__ and (sym.to_s == @__formatter_input__.data.__name__)
		@__formatter_input__.data
	else
		super(sym, *args)
	end
end

Instance Attribute Details

#__delimiter__Object

Returns the value of attribute __delimiter__.



5
6
7
# File 'lib/file_formatter_output_data.rb', line 5

def __delimiter__
  @__delimiter__
end

#__format__Object

Returns the value of attribute __format__.



5
6
7
# File 'lib/file_formatter_output_data.rb', line 5

def __format__
  @__format__
end

#__formatter_input__Object

Returns the value of attribute formatter_input.



5
6
7
# File 'lib/file_formatter_output_data.rb', line 5

def __formatter_input__
  @__formatter_input__
end

#__name__Object

Returns the value of attribute __name__.



5
6
7
# File 'lib/file_formatter_output_data.rb', line 5

def __name__
  @__name__
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/file_formatter_output_data.rb', line 5

def data
  @data
end

Instance Method Details

#__generate_line__Object



34
35
36
37
38
39
40
41
# File 'lib/file_formatter_output_data.rb', line 34

def __generate_line__
	array_out = []
	@data.each do |k,v|
		array_out[k] = __value__(k) if k.is_a?(Fixnum)
	end
	
	CSV.generate_line(array_out, FileFormatter::DATA_DELIMITERS[__delimiter__])
end

#__raw_value__(index) ⇒ Object



27
# File 'lib/file_formatter_output_data.rb', line 27

def __raw_value__(index); @data.fetch(index, ''); end

#__value__(index) ⇒ Object



29
30
31
32
# File 'lib/file_formatter_output_data.rb', line 29

def __value__(index) 
	value = __raw_value__(index).to_s
	instance_eval(value) rescue value
end