Sha256: f66fc64371b2a6cc3fcecbfc937dd3b247166eb3d45cac1df4428e0bf28af447

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

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

4 entries across 4 versions & 1 rubygems

Version Path
relaton-bib-0.3.8 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.7 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.6 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.5 lib/relaton_bib/typed_uri.rb