Hi All (and happy holidays),

I've been playing again with Ruby, trying to think through some details, and also seeing if I can do anything useful with Rails.

Anyway, it occurs to me that it's rather easier for me to think in terms of oo or rdf classes and such, than in terms of SQL schemas or XML trees.

So here's the start of how I'm thinking. It might be a useful framework on which -- among other things -- to port citeproc to C++, to think about GUI details, etc.

Right now it's quite spare (particularly the attributes), but I think the basic approach is right, and is a nice balance of simplicity and flexiblity/expressiveness.

# -- Reference class and subclasses

# the base class
class Reference
  attr_reader :title, :creator, :year, :type
  def initialize(title, creator, year, type)
    @title = title
# not sure how to do this right, but creator ought to be an array of agent objects
    @creator = []
    @year = year
    @type = type
  end
end

# standalone items like books, reports, or albums
class Monograph < Reference
  def initialize(title, creator, year, type, publisher, partOf=nil)
    super(title, creaor, year, type)
    @publisher = publisher
    # partOf is an item-collection relation
    @partOf = partOf
  end
end

# book chapters, parts of reports, etc.
class PartInMonograph < Reference
  def initialize(title, creator, year, type, containedIn, pages)
    super(title, creaor, year, type)
    # containIn is a part-reference relation
    @containedIn = containedIn
    @pages = pages
  end
end

# articles, bills, etc.; items published in serials/periodicals
class PartInSerial < Reference
  def initialize(title, creator, year, type, partOf, pages, volume,
                 issue)
    super(title, creaor, year, type)
    @partOf = partOf
    @pages = pages
    @volume = volume
    @issue = issue
  end
end

# non-citable resources such as periodicals, series, or
# archival collections
class Collection
  def initialize(title)
    @title = title
  end
end

class Periodical < Collection
  def initialize(title)
    super(title)
  end
end

class Series < Collection
  def initialize(title)
    super(title)
  end
end

# -- Agents

class Agent
  attr_reader :name, :sortname
  def initialize(name, sortname)
    @name = name
    @sortname = sortname
  end
end

class Person < Agent
  def initialize(name, sortname)
    super(name, sortname)
  end
end

class Organization < Agent
  def initialize(name, sortname=nil)
    super(name, sortname)
  end
end

class Publisher < Organization
  def initialize(name, place)
    super(name)
    @place = place
  end
end

class Event
  def initialize(name, date, sponsor)
    @name = name
    @date = date
    @sponsor = sponsor
  end
end

class Conference < Event
  def initialize(name, date, sponsor)
    super(name, date, sponsor)
  end
end

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to