Class: FB2rb::Body
- Inherits:
-
Object
- Object
- FB2rb::Body
- Defined in:
- lib/fb2rb.rb
Overview
Holds <body> data
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, content = '') ⇒ Body
constructor
A new instance of Body.
- #to_xml(xml) ⇒ Object
Constructor Details
#initialize(name = nil, content = '') ⇒ Body
Returns a new instance of Body.
677 678 679 680 |
# File 'lib/fb2rb.rb', line 677 def initialize(name = nil, content = '') @name = name @content = content end |
Instance Attribute Details
#content ⇒ String
675 676 677 |
# File 'lib/fb2rb.rb', line 675 def content @content end |
#name ⇒ String?
673 674 675 |
# File 'lib/fb2rb.rb', line 673 def name @name end |
Class Method Details
.parse(xml) ⇒ FB2rb::Body
683 684 685 686 687 688 |
# File 'lib/fb2rb.rb', line 683 def self.parse(xml) Body.new( xml['name'], xml.children.to_s.strip ) end |
Instance Method Details
#to_xml(xml) ⇒ Object
690 691 692 693 694 695 696 697 |
# File 'lib/fb2rb.rb', line 690 def to_xml(xml) return if @content.nil? xml.body do xml.parent['name'] = @name unless @name.nil? xml << @content end end |