Class: DeziDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/dezi/doc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DeziDoc

Returns a new instance of DeziDoc.



38
39
40
41
# File 'lib/dezi/doc.rb', line 38

def initialize(args)
    @fields = {}
    args.each {|k,v| send("#{k}=",v)}
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



31
32
33
# File 'lib/dezi/doc.rb', line 31

def content
  @content
end

#fieldsObject

Returns the value of attribute fields.



36
37
38
# File 'lib/dezi/doc.rb', line 36

def fields
  @fields
end

#mime_typeObject

Returns the value of attribute mime_type.



28
29
30
# File 'lib/dezi/doc.rb', line 28

def mime_type
  @mime_type
end

#mtimeObject

Returns the value of attribute mtime.



33
34
35
# File 'lib/dezi/doc.rb', line 33

def mtime
  @mtime
end

#scoreObject

Returns the value of attribute score.



35
36
37
# File 'lib/dezi/doc.rb', line 35

def score
  @score
end

#sizeObject

Returns the value of attribute size.



34
35
36
# File 'lib/dezi/doc.rb', line 34

def size
  @size
end

#summaryObject

Returns the value of attribute summary.



29
30
31
# File 'lib/dezi/doc.rb', line 29

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



30
31
32
# File 'lib/dezi/doc.rb', line 30

def title
  @title
end

#uriObject

Returns the value of attribute uri.



32
33
34
# File 'lib/dezi/doc.rb', line 32

def uri
  @uri
end

Instance Method Details

#as_stringObject



56
57
58
59
60
61
62
63
# File 'lib/dezi/doc.rb', line 56

def as_string()
    #puts "fields.length=" + @fields.length.to_s
    if @fields.length > 0
        return self.as_xml()
    else
        return @content
    end
end

#as_xmlObject



65
66
67
# File 'lib/dezi/doc.rb', line 65

def as_xml()
    return XmlSimple.xml_out(@fields, {'rootname' => 'doc', 'noattr' => true})
end

#get_field(fname) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/dezi/doc.rb', line 48

def get_field(fname)
    if @fields.has_key?(fname)
        return @fields[fname]
    else
        return nil
    end
end

#set_field(args) ⇒ Object



43
44
45
46
# File 'lib/dezi/doc.rb', line 43

def set_field(args)
    args.each {|k,v| @fields[k] = v}
    @mime_type = 'application/xml'
end