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.



273
274
275
276
# File 'lib/fb2rb.rb', line 273

def initialize(type: '', content: nil)
  @type = type
  @content = content
end

Instance Attribute Details

#contentString?

Returns:

  • (String, nil)


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

def content
  @content
end

#typeString

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.parse(xml) ⇒ FB2rb::CustomInfo

Returns:



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