Sha256: 31abb635cf1c291411b1cfd32b0ff3146e151d8a5cb235af27cebf6df4376175

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

# coding: utf-8

module ONIX2
  class Title
    include Virtus.model

    attribute :title_type, Integer
    attribute :title_text
    attribute :title_prefix
    attribute :title_without_prefix
    attribute :subtitle

    def to_xml
      TitleRepresenter.new(self).to_xml
    end

    def self.from_xml(data)
      TitleRepresenter.new(self.new).from_xml(data)
    end
  end

  class TitleRepresenter < Representable::Decorator
    include Representable::XML

    self.representation_wrap = :Title

    property :title_type, as: "TitleType", render_filter: ::ONIX2::Formatters::TWO_DIGITS
    property :title_text, as: "TitleText"
    property :title_prefix, as: "TitlePrefix"
    property :title_without_prefix, as: "TitleWithoutPrefix"
    property :subtitle, as: "Subtitle"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix2-1.0.0 lib/onix2/title.rb