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.
273 274 275 276 |
# File 'lib/fb2rb.rb', line 273 def initialize(type: '', content: nil) @type = type @content = content end |
Instance Attribute Details
#content ⇒ String?
271 272 273 |
# File 'lib/fb2rb.rb', line 271 def content @content end |
#type ⇒ String
269 270 271 |
# File 'lib/fb2rb.rb', line 269 def type @type end |
Class Method Details
.parse(xml) ⇒ FB2rb::CustomInfo
279 280 281 |
# File 'lib/fb2rb.rb', line 279 def self.parse(xml) CustomInfo.new(type: xml['info-type'], content: xml.text) end |
Instance Method Details
#to_xml(xml) ⇒ Object
283 284 285 286 287 |
# File 'lib/fb2rb.rb', line 283 def to_xml(xml) return if @content.nil? xml.send('custom-info', @content, 'info-type' => @type) end |