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.
630 631 632 633 |
# File 'lib/fb2rb.rb', line 630 def initialize(name = nil, content = '') @name = name @content = content end |
Instance Attribute Details
#content ⇒ String
628 629 630 |
# File 'lib/fb2rb.rb', line 628 def content @content end |
#name ⇒ String?
626 627 628 |
# File 'lib/fb2rb.rb', line 626 def name @name end |
Class Method Details
.parse(xml) ⇒ FB2rb::Body
636 637 638 639 640 641 |
# File 'lib/fb2rb.rb', line 636 def self.parse(xml) Body.new( xml['name'], xml.children.to_s.strip ) end |
Instance Method Details
#to_xml(xml) ⇒ Object
643 644 645 646 647 648 649 650 |
# File 'lib/fb2rb.rb', line 643 def to_xml(xml) return if @content.nil? xml.body do xml.parent['name'] = @name unless @name.nil? xml << @content end end |