Sha256: a19dac614f139305e1e27936b52ddcfa080697412de3bd849b1f46ca828bdf20

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

require "addressable"

module RelatonBib
  # Typed URI
  class TypedUri
    # @return [Symbol] :src/:obp/:rss
    attr_reader :type
    # @retutn [URI]
    attr_reader :content

    # @param type [String] src/obp/rss
    # @param content [String]
    def initialize(type:, content:)
      @type    = type
      @content = Addressable::URI.parse content if content
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.uri(content.to_s, type: type)
    end

    # @return [Hash]
    def to_hash
      { type: type, content: content.to_s }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-bib-0.3.4 lib/relaton_bib/typed_uri.rb