class FakedCSV::Fakerer

Attributes

type[R]

Public Class Methods

new(type) click to toggle source
# File lib/faked_csv/fakerer.rb, line 9
def initialize(type)
    @type = type
    faker, class_name, @method = @type.split ':'
    begin
        @class = Kernel.const_get("Faker::#{_camelize class_name}")
    rescue
        raise "unsupported faker class: #{class_name}"
    end
end

Public Instance Methods

_camelize(str) click to toggle source
# File lib/faked_csv/fakerer.rb, line 27
def _camelize(str)
    str.split('_').map {|w| w.capitalize}.join
end
fake() click to toggle source
# File lib/faked_csv/fakerer.rb, line 19
def fake
    begin
        @class.send @method
    rescue
        raise "unsupported faker method: #{@method}"
    end
end