Class: FB2rb::CustomInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/fb2rb.rb

Overview

Holds <custom-info> data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#contentString?

Returns:

  • (String, nil)


270
271
272
# File 'lib/fb2rb.rb', line 270

def content
  @content
end

#typeString

Returns:

  • (String)


268
269
270
# File 'lib/fb2rb.rb', line 268

def type
  @type
end

Class Method Details

.parse(xml) ⇒ FB2rb::CustomInfo

Returns:



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