Class: Sablon::DOM::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/sablon/document_object_model/model.rb

Overview

Object to represent an entire template and it’s XML contents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zip_io_stream) ⇒ Model

setup the DOM by reading and storing all XML files in the template in memory



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/sablon/document_object_model/model.rb', line 43

def initialize(zip_io_stream)
  @current_entry = nil
  @zip_contents = {}
  zip_io_stream.each do |entry|
    next unless entry.file?
    content = entry.get_input_stream.read
    @zip_contents[entry.name] = wrap_entry(entry.name, content)
  end
  #
  @dom = build_dom(@zip_contents)
end

Instance Attribute Details

#current_entryObject

Returns the value of attribute current_entry.



38
39
40
# File 'lib/sablon/document_object_model/model.rb', line 38

def current_entry
  @current_entry
end

#zip_contentsObject (readonly)

Returns the value of attribute zip_contents.



39
40
41
# File 'lib/sablon/document_object_model/model.rb', line 39

def zip_contents
  @zip_contents
end

Instance Method Details

#[](entry_name) ⇒ Object

Returns the corresponding DOM handled file



56
57
58
# File 'lib/sablon/document_object_model/model.rb', line 56

def [](entry_name)
  @dom[entry_name]
end