class Tardef::File
Attributes
editor[RW]
extension_defs[RW]
filename[RW]
imports[RW]
last_changed[RW]
lists[RW]
schema[RW]
tasks[RW]
title[RW]
Public Class Methods
new(filename, protocol_version, last_changed = Time.now.iso8601(0), title = "", editor = "", imports = [], schema = Tardef::DEFAULT_SCHEMA)
click to toggle source
Calls superclass method
Tardef::Base::new
# File lib/tardef/base.rb, line 57 def initialize(filename, protocol_version, last_changed = Time.now.iso8601(0), title = "", editor = "", imports = [], schema = Tardef::DEFAULT_SCHEMA) super() @filename, @last_changed, @title = filename, last_changed, title @editor, @lists, @tags, @tasks, @imports = editor, [], [], [], imports @schema = schema end
Public Instance Methods
add_list(list)
click to toggle source
# File lib/tardef/base.rb, line 64 def add_list(list) @lists << list end
add_tag(tag)
click to toggle source
# File lib/tardef/base.rb, line 68 def add_tag(tag) @tags << tag end
add_task(task)
click to toggle source
# File lib/tardef/base.rb, line 72 def add_task(task) @tasks << task end
has_list?(uid)
click to toggle source
# File lib/tardef/base.rb, line 76 def has_list?(uid) hash_has_object?(@lists, uid) end
has_tag?(tag)
click to toggle source
# File lib/tardef/base.rb, line 80 def has_tag?(tag) hash_has_object?(@tags, tag) end
has_task?(task)
click to toggle source
# File lib/tardef/base.rb, line 84 def has_task?(task) hash_has_object?(@tasks, task) end
to_hash()
click to toggle source
# File lib/tardef/base.rb, line 88 def to_hash hash = {"meta" => { "title" => @title, "editor" => @editor, "last_changed" => @last_changed, "imports" => @imports }, "lists" => @lists, "tags" => @tags, "tasks" => @tasks, "schema" => @schema, "extensions" => @extensions, } items = [] ["lists", "tags", "tasks", "extensions"].each do |type| next if not hash[type] items = [] hash[type].each do |item| items << item.to_hash end hash[type] = items end return hash end
Private Instance Methods
hash_has_object?(list, uid)
click to toggle source
# File lib/tardef/base.rb, line 110 def hash_has_object?(list, uid) list.each { |item| return true if item.uid == uid } return false end