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.
678 679 680 681 |
# File 'lib/fb2rb.rb', line 678 def initialize(name: nil, content: '') @name = name @content = content end |
Instance Attribute Details
#content ⇒ String
676 677 678 |
# File 'lib/fb2rb.rb', line 676 def content @content end |
#name ⇒ String?
674 675 676 |
# File 'lib/fb2rb.rb', line 674 def name @name end |
Class Method Details
.parse(xml) ⇒ FB2rb::Body
684 685 686 687 688 689 |
# File 'lib/fb2rb.rb', line 684 def self.parse(xml) Body.new( name: xml['name'], content: xml.children.to_s.strip ) end |
Instance Method Details
#to_xml(xml) ⇒ Object
691 692 693 694 695 696 697 698 |
# File 'lib/fb2rb.rb', line 691 def to_xml(xml) return if @content.nil? xml.body do xml.parent['name'] = @name unless @name.nil? xml << @content end end |