Class: Presser::PresserDoc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PresserDoc

Returns a new instance of PresserDoc.



7
8
9
10
11
# File 'lib/presser_doc.rb', line 7

def initialize *args
  @title       = args[0]        || "This is the title"
  @link        = args[1]        || "http://www.google.com"
  @description = args[2]        || "This is the description"
end

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



6
7
8
# File 'lib/presser_doc.rb', line 6

def categories
  @categories
end

#post_statusObject

Returns the value of attribute post_status.



6
7
8
# File 'lib/presser_doc.rb', line 6

def post_status
  @post_status
end

#postidObject

Returns the value of attribute postid.



6
7
8
# File 'lib/presser_doc.rb', line 6

def postid
  @postid
end

Instance Method Details

#new_docObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/presser_doc.rb', line 23

def new_doc
  doc         = REXML::Document.new
  item        = doc.add_element  "struct"
  title       = item.add_element 'title'
  link        = item.add_element "link"
  description = item.add_element "description"

  description.text = @description
  title.text       = @title
  link.text        = @link

  # str = ""
  # doc.write(str, 2)
  # puts str
  str = ""
  doc.write str
  str
end

#to_sObject



13
14
15
16
17
18
19
20
21
# File 'lib/presser_doc.rb', line 13

def to_s
  str = %Q{# Beginning of header
title:  #{@title}
link:   #{@link}
postid: #{postid}
post_status: #{post_status}
# End of header
#{@description}}
end