Sha256: 22dd0cfb18b8c9a1e39bab9babf8c782985a2fd2c91f2ee18cbe617daf9b4061

Contents?: true

Size: 605 Bytes

Versions: 8

Compression:

Stored size: 605 Bytes

Contents

require "addressable"

module RelatonBib
  # Typed URI
  class TypedUri
    # @return [Symbol] :src/:obp/:rss
    attr_reader :type
    # @retutn [URI]
    attr_accessor :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

8 entries across 8 versions & 1 rubygems

Version Path
relaton-bib-0.5.1 lib/relaton_bib/typed_uri.rb
relaton-bib-0.5.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.4.1 lib/relaton_bib/typed_uri.rb
relaton-bib-0.4.0 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.12 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.11 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.10 lib/relaton_bib/typed_uri.rb
relaton-bib-0.3.9 lib/relaton_bib/typed_uri.rb