Sha256: 73dfce9a1ea2fa9b61aab6e83d7c6bd8f1b9b955143b2c7648c4c0488f250995
Contents?: true
Size: 1.11 KB
Versions: 21
Compression:
Stored size: 1.11 KB
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, NilClass] src/obp/rss # @param content [String] def initialize(type: nil, 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) doc = builder.uri content.to_s doc[:type] = type if type end # @return [Hash] def to_hash hash = { "content" => content.to_s } hash["type"] = type.to_s if type hash end # @param prefix [String] # @param count [Integer] number of links # @return [String] def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? "link" : prefix + ".link" out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}.type:: #{type}\n" if type out += "#{pref}.content:: #{content}\n" out end end end
Version data entries
21 entries across 21 versions & 1 rubygems