Class: QDA::Document

Inherits:
Fragment show all
Defined in:
lib/weft/document.rb

Instance Attribute Summary collapse

Attributes inherited from Fragment

#docid, #doctitle, #offset

Instance Method Summary collapse

Methods inherited from Fragment

#==, #coerce, #complete?, #scan, #text, #to_code

Methods included from Coding

#<=>, #end, #exclude, #include?, #intersect, #overlap?, #prepare_args, #touch?, #union

Constructor Details

#initialize(title, text = '', memo = '', create_date = Time.now(), mod_date = Time.now()) ⇒ Document

expects dbid to be set later



90
91
92
93
94
95
96
97
98
99
# File 'lib/weft/document.rb', line 90

def initialize( title, text = '', memo = '', 
                create_date = Time.now(), 
                mod_date = Time.now() )
  super(text, title, 0)
	@title = title
  @memo  = memo
  
  @create_date = create_date
  @mod_date    = mod_date
end

Instance Attribute Details

#create_dateObject (readonly)

Returns the value of attribute create_date.



86
87
88
# File 'lib/weft/document.rb', line 86

def create_date
  @create_date
end

#dbidObject

Returns the value of attribute dbid.



86
87
88
# File 'lib/weft/document.rb', line 86

def dbid
  @dbid
end

#memoObject

Returns the value of attribute memo.



87
88
89
# File 'lib/weft/document.rb', line 87

def memo
  @memo
end

#metaObject (readonly)

Returns the value of attribute meta.



86
87
88
# File 'lib/weft/document.rb', line 86

def meta
  @meta
end

#mod_dateObject (readonly)

Returns the value of attribute mod_date.



86
87
88
# File 'lib/weft/document.rb', line 86

def mod_date
  @mod_date
end

#titleObject

Returns the value of attribute title.



87
88
89
# File 'lib/weft/document.rb', line 87

def title
  @title
end

Instance Method Details

#[](from, num_chars) ⇒ Object



122
123
124
# File 'lib/weft/document.rb', line 122

def [](from, num_chars)
	Fragment.new(super, title, from, @dbid)
end

#append(text, term_char = "\n") ⇒ Object

def append(text, fragtype = 0) returns the number of characters appended



116
117
118
119
120
# File 'lib/weft/document.rb', line 116

def append(text, term_char = "\n")
  ins = text.gsub(/[\r\n]+$/, '') + term_char
	self << ins
  ins.length 
end

#createObject

marks the document as created now



110
111
112
# File 'lib/weft/document.rb', line 110

def create()
  @create_date = Time.now()
end

#inspectObject



126
127
128
# File 'lib/weft/document.rb', line 126

def inspect()
  "<*Document #{dbid} '#{title}' (#{length} chars)>"
end