Class: KjDotXml

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

Instance Method Summary collapse

Constructor Details

#initialize(title = nil) ⇒ KjDotXml

Returns a new instance of KjDotXml.



82
83
84
# File 'lib/kjdotxml.rb', line 82

def initialize(title=nil)
  book(title) if title
end

Instance Method Details

#book(s) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/kjdotxml.rb', line 86

def book(s)
      
  filename = s.downcase.gsub(/\s/,'-') + '.xml'
  #filepath = File.join('/tmp', filename)
  filepath = File.join(File.dirname(__FILE__), '..', 'xml', filename)
  
  if File.exists? filepath then
    
    contents = File.read(filepath)
    @doc = Rexle.new(contents)
    
  else
    raise KjDotXmlError, 'book not found'
  end
  
end

#booksObject



103
104
105
# File 'lib/kjdotxml.rb', line 103

def books()
  BOOKS
end

#to_docObject



107
108
109
# File 'lib/kjdotxml.rb', line 107

def to_doc()
  @doc
end