class Tardef::Connector::Base

Attributes

filename[RW]

Public Class Methods

new(filename) click to toggle source
# File lib/tardef/connector/base.rb, line 39
def initialize(filename)
  @filename = filename
end

Public Instance Methods

read() click to toggle source
# File lib/tardef/connector/base.rb, line 6
def read
  hash = read_file
  file = Tardef::File.new(nil, nil, nil)
  file.load_hash(hash["meta"])
  file.filename = @filename

  list, tag, task = Tardef::List, Tardef::Tag, Tardef::Task
  extension       = Tardef::Extension
  entries = {"lists" => list, "tags" => tag, "tasks" => task,
             "extensions" => extension}
  
  entries.map do |key, value|
    next unless hash[key]
    hash[key].each do |hsh|
      entry = value.new("", "", "")
      entry.load_hash(hsh)
      file << entry
    end
  end
  
  file.schema = hash["schema"] if hash["schema"]
  file
end
set_filename(filename) click to toggle source
# File lib/tardef/connector/base.rb, line 35
def set_filename(filename)
  @filename = filename
end
write(file_object) click to toggle source
# File lib/tardef/connector/base.rb, line 30
def write(file_object)
  hash = file_object.to_hash
  write_file(hash)
end