Class: Thepub::Epub::OPF::Metadata

Inherits:
Struct
  • Object
show all
Defined in:
lib/thepub/epub/opf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#creatorObject

Returns the value of attribute creator

Returns:

  • (Object)

    the current value of creator



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def creator
  @creator
end

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def date
  @date
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def description
  @description
end

#identifierObject

Returns the value of attribute identifier

Returns:

  • (Object)

    the current value of identifier



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def identifier
  @identifier
end

#languageObject

Returns the value of attribute language

Returns:

  • (Object)

    the current value of language



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def language
  @language
end

#publisherObject

Returns the value of attribute publisher

Returns:

  • (Object)

    the current value of publisher



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def publisher
  @publisher
end

#relationObject

Returns the value of attribute relation

Returns:

  • (Object)

    the current value of relation



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def relation
  @relation
end

#rightsObject

Returns the value of attribute rights

Returns:

  • (Object)

    the current value of rights



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def rights
  @rights
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def subject
  @subject
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



21
22
23
# File 'lib/thepub/epub/opf.rb', line 21

def title
  @title
end

Instance Method Details

#to_xml(builder) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/thepub/epub/opf.rb', line 34

def to_xml(builder)
  builder. 'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
    'xmlns:dcterms' => "http://purl.org/dc/terms/",
    'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
    'xmlns:opf' => "http://www.idpf.org/2007/opf" do
      # Required elements
      builder.dc :title do
        builder << self.title
      end
      builder.dc :language, 'xsi:type' => "dcterms:RFC3066" do
        builder << self.language
      end
      builder.dc :identifier, :id => 'dcidid', 'opf:scheme' => 'URI' do
        builder << self.identifier
      end
      # Optional elements
      builder.dc :subject do
        builder << self.subject
      end if self.subject
      builder.dc :description do
        builder << self.description
      end if self.description
      builder.dc :relation do
        builder << self.relation
      end if self.relation
      builder.dc :creator, 'opf:role' => "aut" do     # TODO: roles
        builder << self.creator
      end if self.creator
      builder.dc :publisher do
        builder << self.publisher
      end if self.publisher
      builder.dc :date do
        builder << self.date.to_s
      end if self.date
      builder.dc :rights do
        builder << self.rights
      end if self.rights
  end
end