Sha256: 4bbfa992bfb8d8705693705e779bf4c194dd227cd7b71665df41b6a2e5f1bd6b

Contents?: true

Size: 704 Bytes

Versions: 6

Compression:

Stored size: 704 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

    # @parma url [String]
    def content=(url)
      @content = Addressable::URI.parse url
    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

6 entries across 6 versions & 1 rubygems

Version Path
relaton-bib-0.9.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.8.1 lib/relaton_bib/typed_uri.rb
relaton-bib-0.8.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.7.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.6.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.5.2 lib/relaton_bib/typed_uri.rb