Class: GoogleApps::DocumentHandler
- Inherits:
-
Object
- Object
- GoogleApps::DocumentHandler
- Defined in:
- lib/google_apps/document_handler.rb
Instance Method Summary collapse
-
#create_doc(text, type = nil) ⇒ Object
create_doc creates a document of the specified format from the given string.
-
#doc_of_type(text, type) ⇒ Object
doc_of_type takes a document type and a string and returns a document of that type in the current format.
-
#initialize ⇒ DocumentHandler
constructor
A new instance of DocumentHandler.
-
#unknown_type(text) ⇒ Object
unknown_type takes a string and returns a document of of the corresponding @format.
Constructor Details
#initialize ⇒ DocumentHandler
Returns a new instance of DocumentHandler.
3 4 5 |
# File 'lib/google_apps/document_handler.rb', line 3 def initialize @documents = look_up_doc_types end |
Instance Method Details
#create_doc(text, type = nil) ⇒ Object
create_doc creates a document of the specified format from the given string.
9 10 11 |
# File 'lib/google_apps/document_handler.rb', line 9 def create_doc(text, type = nil) @documents.include?(type) ? doc_of_type(text, type) : unknown_type(text) end |
#doc_of_type(text, type) ⇒ Object
doc_of_type takes a document type and a string and returns a document of that type in the current format.
21 22 23 24 25 |
# File 'lib/google_apps/document_handler.rb', line 21 def doc_of_type(text, type) raise "No Atom document of type: #{type}" unless @documents.include?(type.to_s) GoogleApps::Atom.send(type, text) end |
#unknown_type(text) ⇒ Object
unknown_type takes a string and returns a document of of the corresponding @format.
15 16 17 |
# File 'lib/google_apps/document_handler.rb', line 15 def unknown_type(text) Atom::XML::Document.string(text) end |