Sha256: f9fae7cda6110a76513a5ae2cd5475b63bb88496dc2ad0a8ff8fa2d7233e4ed1

Contents?: true

Size: 912 Bytes

Versions: 2

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true
require 'happymapper'
require_relative './node'
require_relative './length'
require_relative './price'
require_relative './rixml_type/normalized_string'
require_relative './rixml_type/yes_no_boolean'

module RixmlDocument
  class Resource < Node
    include HappyMapper
    tag 'Resource'

    has_one :length, Length, tag: 'Length', xpath: './'
    has_one :price, Price, tag: 'Price', xpath: './'

    attribute :resource_id, RixmlType::NormalizedString, tag: 'resourceID'
    attribute :language, RixmlType::NormalizedString, tag: 'language'
    attribute :primary_indicator, RixmlType::YesNoBoolean, tag: 'primaryIndicator'
    attribute :size_in_bytes, Integer, tag: 'sizeInBytes'

    element :mime_type, String, tag: 'MIMEType'
    element :name, String, tag: 'Name'

    def number_of_pages
      return if length.nil?

      length.value if length.pages?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rixml-0.5.9 lib/rixml_document/resource.rb
rixml-0.5.8 lib/rixml_document/resource.rb