Class: DIDX::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/didx/generic.rb

Direct Known Subclasses

Key, Web

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(did_string) ⇒ Generic

Returns a new instance of Generic.

Raises:



6
7
8
9
10
11
12
# File 'lib/didx/generic.rb', line 6

def initialize(did_string)
  @id = did_string
  @prefix, @method, @method_id = did_string.split(":", 3)
  parse_method_id
  raise Error, "Invalid DID: #{did_string.inspect}" unless @prefix == "did"
  @document = nil
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/didx/generic.rb', line 5

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



5
6
7
# File 'lib/didx/generic.rb', line 5

def method
  @method
end

#method_idObject (readonly)

Returns the value of attribute method_id.



5
6
7
# File 'lib/didx/generic.rb', line 5

def method_id
  @method_id
end

#prefixObject (readonly)

Returns the value of attribute prefix.



5
6
7
# File 'lib/didx/generic.rb', line 5

def prefix
  @prefix
end

Instance Method Details

#documentObject



14
15
16
# File 'lib/didx/generic.rb', line 14

def document
  @document ||= Document.new(resolve)
end