class CsvBuilder::CsvProxy

Public Class Methods

new(data, options = {}) click to toggle source
Calls superclass method
# File lib/csv_builder/csv_proxy.rb, line 6
def initialize(data, options = {})
  super(data, options).tap do

    init(CSV.new(data, @options), data) do

      @ivar_names = base.instance_variables.select do |ivar|
        CSV::DEFAULT_OPTIONS.keys.map { |key| "@#{key}" }.include?(ivar.to_s)
      end
    end

  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/csv_builder/csv_proxy.rb, line 19
def [](key)
  if @ivar_names.include?(ivar_key = "@#{key}".intern)
    base.instance_variable_get(ivar_key)
  end
end
[]=(key, value) click to toggle source
# File lib/csv_builder/csv_proxy.rb, line 25
def []=(key, value)
  if @ivar_names.include?(ivar_key = "@#{key}".intern)
    base.instance_variable_set(ivar_key, value)
  end
end
settings() click to toggle source
# File lib/csv_builder/csv_proxy.rb, line 31
def settings
  @ivar_names.inject({}) do |hash,key|
    hash.tap do
      hash[key.to_s[1..-1].intern] = base.instance_variable_get(key)
    end
  end
end