Class: FB2rb::CustomInfo
- Inherits:
-
Object
- Object
- FB2rb::CustomInfo
- Defined in:
- lib/fb2rb.rb
Overview
Holds <custom-info> data
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type: '', content: nil) ⇒ CustomInfo
constructor
A new instance of CustomInfo.
- #to_xml(xml) ⇒ Object
Constructor Details
#initialize(type: '', content: nil) ⇒ CustomInfo
Returns a new instance of CustomInfo.
272 273 274 275 |
# File 'lib/fb2rb.rb', line 272 def initialize(type: '', content: nil) @type = type @content = content end |
Instance Attribute Details
#content ⇒ String?
270 271 272 |
# File 'lib/fb2rb.rb', line 270 def content @content end |
#type ⇒ String
268 269 270 |
# File 'lib/fb2rb.rb', line 268 def type @type end |
Class Method Details
.parse(xml) ⇒ FB2rb::CustomInfo
278 279 280 |
# File 'lib/fb2rb.rb', line 278 def self.parse(xml) CustomInfo.new(type: xml['info-type'], content: xml.text) end |
Instance Method Details
#to_xml(xml) ⇒ Object
282 283 284 285 286 |
# File 'lib/fb2rb.rb', line 282 def to_xml(xml) return if @content.nil? xml.send('custom-info', @content, 'info-type' => @type) end |