Class: TmxParser::Document
- Inherits:
-
Object
- Object
- TmxParser::Document
- Includes:
- Enumerable
- Defined in:
- lib/tmx-parser/document.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#string_or_file_handle ⇒ Object
readonly
Returns the value of attribute string_or_file_handle.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(string_or_file_handle, encoding = Encoding.default_external) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(string_or_file_handle, encoding = Encoding.default_external) ⇒ Document
Returns a new instance of Document.
10 11 12 13 |
# File 'lib/tmx-parser/document.rb', line 10 def initialize(string_or_file_handle, encoding = Encoding.default_external) @string_or_file_handle = string_or_file_handle @encoding = encoding end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
8 9 10 |
# File 'lib/tmx-parser/document.rb', line 8 def encoding @encoding end |
#string_or_file_handle ⇒ Object (readonly)
Returns the value of attribute string_or_file_handle.
8 9 10 |
# File 'lib/tmx-parser/document.rb', line 8 def string_or_file_handle @string_or_file_handle end |
Instance Method Details
#each(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tmx-parser/document.rb', line 15 def each(&block) if block_given? listener = Listener.new(&block) document = SaxDocument.new(listener) parser = Nokogiri::XML::SAX::Parser.new(document, encoding.to_s) parser.parse(string_or_file_handle) else to_enum(__method__) end end |