class Qiflib::Category

Instances of this class represent a catgory parsed within the !Type:Cat section of a qif file. The qiflib gem only captures the category name, and not the other fields.

Attributes

id[RW]
name[RW]

Public Class Methods

csv_header() click to toggle source

Return the CSV header row.

# File lib/qiflib_category.rb, line 15
def self.csv_header
  CSV.generate do | csv |
    csv << Qiflib::csv_category_field_names
  end 
end
new(n=0) click to toggle source

Constructor. The given n arg is an integer id value; defaults to 0.

# File lib/qiflib_category.rb, line 23
def initialize(n=0)
  @id, @name = 0, "#{n}".strip.downcase
end

Public Instance Methods

as_array(idx=0) click to toggle source

Return this instance an 2-element array; id and name.

# File lib/qiflib_category.rb, line 37
def as_array(idx=0)
  array = []
  array << idx + 1
  array << name
  array
end
to_csv(idx=0) click to toggle source

Return this instance a CSV row.

# File lib/qiflib_category.rb, line 29
def to_csv(idx=0)
  CSV.generate do | csv |
    csv << as_array(idx)
  end 
end