module CsvPirate::PirateShip::ClassMethods

Public Instance Methods

blindfold(args = {}) click to toggle source

returns the csv_pirate object so you have access to everything warning if using from console: if you are exporting a large csv this will all print in your console. If using in a download action it might look like this: csv_pirate = Make.blindfold send_data csv_pirate.maroon,

:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=#{csv_pirate.nocturnal}"
# File lib/csv_pirate/pirate_ship.rb, line 98
def blindfold(args = {})
  TheCapn.create(self.piratey_args(args))
end
land_ho(args = {}) click to toggle source

returns the csv_pirate object so you have access to everything Does not actually create the csv, so you need to do this in your code:

csv_pirate = Klass.land_ho({:booty => [:id, :name, :dragons, :created_at]})

This allows you to modify the csv_pirate object before creating the csv like this:

csv_pirate.booty -= [:id, :name]
csv_pirate.hoist_mainstay()
# File lib/csv_pirate/pirate_ship.rb, line 108
def land_ho(args = {})
  TheCapn.new(self.piratey_args(args))
end
raise_anchor(permanence = {:new => :new}, args = {}) click to toggle source
# File lib/csv_pirate/pirate_ship.rb, line 121
def raise_anchor(permanence = {:new => :new}, args = {})
  pargs = self.piratey_args(args)
  pargs.merge!({
          :chart => pargs[:chart] + ["dumps"],
          :brigantine => :last
  })
  csv_pirate = TheCapn.new(pargs)

  csv_pirate.to_memory(permanence)
end
walk_the_plank(args = {}) click to toggle source

returns the text of the csv export (not the file - this is important if you are appending) warning if using from console: if you are exporting a large csv this will all print in your console. intended for use with send_data for downloading the text of the csv: send_data Make.walk_the_plank,

:type => 'text/csv; charset=iso-8859-1; header=present',
:disposition => "attachment; filename=Data.csv"
# File lib/csv_pirate/pirate_ship.rb, line 87
def walk_the_plank(args = {})
  self.land_ho(args).hoist_mainstay()
end
weigh_anchor(args = {}) click to toggle source
# File lib/csv_pirate/pirate_ship.rb, line 112
def weigh_anchor(args = {})
  pargs = self.piratey_args(args)
  pargs.merge!({
          :gibbet => '.dump',
          :chart => pargs[:chart] + ["dumps"],
  })
  TheCapn.create(pargs)
end

Protected Instance Methods

get_chronometer(chron) click to toggle source
# File lib/csv_pirate/pirate_ship.rb, line 152
def get_chronometer(chron)
  chron == false ?
          false :
          (chron || (self.piratey_options[:chronometer] == false ?
                  false :
                  (self.piratey_options[:chronometer] || Date.today)))
end
piratey_args(args = {}) click to toggle source
# File lib/csv_pirate/pirate_ship.rb, line 134
def piratey_args(args = {})
  TheCapn.parlay ||= args[:parlay] || self.piratey_options[:parlay]
  return { :chart => args[:chart] || self.piratey_options[:chart],
    :aft => args[:aft] || self.piratey_options[:aft],
    :gibbet => args[:gibbet] || self.piratey_options[:gibbet],
    :chronometer => get_chronometer(args[:chronometer]),
    :waggoner => args[:waggoner] || self.piratey_options[:waggoner] || "#{self}",
    :swag => args[:swag] || self.piratey_options[:swag],
    :swab => args[:swab] || self.piratey_options[:swab],
    :mop => args[:mop] || self.piratey_options[:mop],
    :shrouds => args[:shrouds] || self.piratey_options[:shrouds],
    :grub => args[:grub] || self.piratey_options[:grub],
    :spyglasses => args[:spyglasses] || self.piratey_options[:spyglasses],
    :booty => args[:booty] || self.piratey_options[:booty],
    :blackjack => args[:blackjack] || self.piratey_options[:blackjack],
    :bury_treasure => args[:bury_treasure] || self.piratey_options[:bury_treasure] }
end