Class: Officedoc::Package::Raw::PartList
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Officedoc::Package::Raw::PartList
- Defined in:
- lib/officedoc/package/raw/parts.rb
Constant Summary collapse
- EntryName =
'[Content_Types].xml'
Instance Method Summary collapse
-
#initialize(zip_file) {|_self| ... } ⇒ PartList
constructor
A new instance of PartList.
- #of_type(type, regexp: false, partial: false) ⇒ Object
- #read_from(zip_file) ⇒ Object
Constructor Details
#initialize(zip_file) {|_self| ... } ⇒ PartList
Returns a new instance of PartList.
34 35 36 37 38 39 |
# File 'lib/officedoc/package/raw/parts.rb', line 34 def initialize(zip_file) __setobj__([]) @zip_file = zip_file read_from zip_file if zip_file yield self if block_given? end |
Instance Method Details
#of_type(type, regexp: false, partial: false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/officedoc/package/raw/parts.rb', line 50 def of_type( type, regexp: false, partial: false ) select do |part| if regexp part.type.match(type) elsif partial part.type.include?(type) else part.type == type end end end |
#read_from(zip_file) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/officedoc/package/raw/parts.rb', line 41 def read_from(zip_file) zip_file.entry_read_stream( EntryName ) do |stream| doc = Nokogiri::XML(stream) doc.css("Override[@PartName]").each do |node| push Officedoc::Package::Raw::Part.new @zip_file, node end end end |