Class: RelatonBib::TypedUri

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/typed_uri.rb

Overview

Typed URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, content:) ⇒ TypedUri

Returns a new instance of TypedUri.

Parameters:

  • type (String)

    src/obp/rss

  • content (String)


13
14
15
16
# File 'lib/relaton_bib/typed_uri.rb', line 13

def initialize(type:, content:)
  @type    = type
  @content = Addressable::URI.parse content if content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/relaton_bib/typed_uri.rb', line 9

def content
  @content
end

#typeSymbol (readonly)

Returns :src/:obp/:rss.

Returns:

  • (Symbol)

    :src/:obp/:rss



7
8
9
# File 'lib/relaton_bib/typed_uri.rb', line 7

def type
  @type
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


24
25
26
# File 'lib/relaton_bib/typed_uri.rb', line 24

def to_hash
  { "type" => type, "content" => content.to_s }
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


19
20
21
# File 'lib/relaton_bib/typed_uri.rb', line 19

def to_xml(builder)
  builder.uri(content.to_s, type: type)
end