Class: FB2rb::Coverpage

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

Overview

Holds <coverpage> data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(images = []) ⇒ Coverpage

Returns a new instance of Coverpage.



490
491
492
# File 'lib/fb2rb.rb', line 490

def initialize(images = [])
  @images = images
end

Instance Attribute Details

#imagesArray<String>

Returns:

  • (Array<String>)


488
489
490
# File 'lib/fb2rb.rb', line 488

def images
  @images
end

Class Method Details

.parse(xml, fb2_prefix, xlink_prefix) ⇒ Object



494
495
496
497
498
# File 'lib/fb2rb.rb', line 494

def self.parse(xml, fb2_prefix, xlink_prefix)
  Coverpage.new(
    xml.xpath("./#{fb2_prefix}:image/@#{xlink_prefix}:href").map(&:to_s)
  )
end

Instance Method Details

#to_xml(xml) ⇒ Object



500
501
502
503
504
505
506
# File 'lib/fb2rb.rb', line 500

def to_xml(xml)
  xml.coverpage do
    @images.each do |image|
      xml.image('l:href' => image)
    end
  end
end