Class: OpenCoinage::Issuer

Inherits:
Object
  • Object
show all
Defined in:
lib/opencoinage/issuer.rb

Overview

A digital currency issuer.

Constant Summary

RDF_TYPE =
Vocabulary[:Issuer]

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Issuer) initialize(uri = nil, options = {})

Initializes the issuer.

Parameters:

  • (RDF::URI, String, #to_s) uri (defaults to: nil)

    a valid URI identifying the issuer

  • (Hash{Symbol => Object}) options (defaults to: {})

Options Hash (options):

  • (String) :name — default: nil

    the name of the issuer



15
16
17
18
# File 'lib/opencoinage/issuer.rb', line 15

def initialize(uri = nil, options = {})
  @uri  = RDF::URI(uri || UUID.generate(:urn))
  @name = options[:name] if options.has_key?(:name)
end

Instance Attribute Details

- (String) name

The name of this issuer.

Returns:

  • (String)

See Also:



32
33
34
# File 'lib/opencoinage/issuer.rb', line 32

def name
  @name
end

- (RDF::URI) uri (readonly) Also known as: to_uri

The URI identifying this issuer.

Returns:

  • (RDF::URI)


24
25
26
# File 'lib/opencoinage/issuer.rb', line 24

def uri
  @uri
end

Instance Method Details

- (Hash) to_hash

Returns the hash table representation of this issuer.

Returns:

  • (Hash)


38
39
40
# File 'lib/opencoinage/issuer.rb', line 38

def to_hash
  {:name => name}
end

- (String) to_json

Returns the JSON representation of this issuer.



48
49
50
51
# File 'lib/opencoinage/issuer.rb', line 48

def to_json
  require 'json' unless defined?(::JSON)
  to_hash.to_json
end

- (RDF::Graph) to_rdf(options = {})

Returns the RDF representation of this issuer.

Parameters:

  • (Hash{Symbol => Object}) options (defaults to: {})

Options Hash (options):

  • (RDF::Resource) :context — default: nil

Returns:

  • (RDF::Graph)

See Also:



61
62
63
64
65
66
# File 'lib/opencoinage/issuer.rb', line 61

def to_rdf(options = {})
  RDF::Graph.new(options[:context]) do |graph|
    graph << [uri, RDF.type, self.class.const_get(:RDF_TYPE)]
    graph << [uri, RDF::FOAF.name, name] if name
  end
end