Class: EeePub::ContainerItem Abstract
- Inherits:
-
Object
- Object
- EeePub::ContainerItem
- Defined in:
- lib/eeepub/container_item.rb
Overview
This class is abstract.
Abstract base class for container item of ePub. Provides some helper methods.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(values) ⇒ ContainerItem
constructor
A new instance of ContainerItem.
-
#save(filepath) ⇒ Object
Save as container item.
-
#set_values(values) ⇒ Object
Set values for attributes.
-
#to_xml ⇒ String
Convert to xml of container item.
Constructor Details
#initialize(values) ⇒ ContainerItem
Returns a new instance of ContainerItem.
35 36 37 |
# File 'lib/eeepub/container_item.rb', line 35 def initialize(values) set_values(values) end |
Instance Method Details
#save(filepath) ⇒ Object
Save as container item
62 63 64 65 66 |
# File 'lib/eeepub/container_item.rb', line 62 def save(filepath) File.open(filepath, 'w') do |file| file << self.to_xml end end |
#set_values(values) ⇒ Object
Set values for attributes
42 43 44 45 46 |
# File 'lib/eeepub/container_item.rb', line 42 def set_values(values) values.each do |k, v| self.send(:"#{k}=", v) end end |
#to_xml ⇒ String
Convert to xml of container item
51 52 53 54 55 56 57 |
# File 'lib/eeepub/container_item.rb', line 51 def to_xml out = "" builder = Builder::XmlMarkup.new(:target => out, :indent => 2) builder.instruct! build_xml(builder) out end |