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.



520
521
522
# File 'lib/fb2rb.rb', line 520

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

Instance Attribute Details

#imagesArray<String>

Returns:

  • (Array<String>)


518
519
520
# File 'lib/fb2rb.rb', line 518

def images
  @images
end

Class Method Details

.parse(xml, fb2_prefix, xlink_prefix) ⇒ Object



524
525
526
527
528
# File 'lib/fb2rb.rb', line 524

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



530
531
532
533
534
535
536
# File 'lib/fb2rb.rb', line 530

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