Class: Iglu::SchemaKey

Inherits:
Struct
  • Object
show all
Defined in:
lib/iglu-client/core.rb

Overview

Class holding Schema metadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formatObject

Returns the value of attribute format

Returns:

  • (Object)

    the current value of format



43
44
45
# File 'lib/iglu-client/core.rb', line 43

def format
  @format
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



43
44
45
# File 'lib/iglu-client/core.rb', line 43

def name
  @name
end

#vendorObject

Returns the value of attribute vendor

Returns:

  • (Object)

    the current value of vendor



43
44
45
# File 'lib/iglu-client/core.rb', line 43

def vendor
  @vendor
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



43
44
45
# File 'lib/iglu-client/core.rb', line 43

def version
  @version
end

Class Method Details

.parse_key(key) ⇒ Object

Construct SchemaKey from URI



56
57
58
59
60
61
62
63
64
# File 'lib/iglu-client/core.rb', line 56

def self.parse_key(key)
  vendor, name, format, version = key.scan(URI_REGEX).flatten
  if vendor.nil? or name.nil? or format.nil? or version.nil?
    raise IgluError.new "Schema key [#{key}] is not valid Iglu URI"
  else
    schema_ver = SchemaVer.parse_schemaver(version)
    SchemaKey.new vendor, name, format, schema_ver
  end
end

Instance Method Details

#as_pathObject

Render as plain path



51
52
53
# File 'lib/iglu-client/core.rb', line 51

def as_path
  "#{vendor}/#{name}/#{format}/#{version.as_string}"
end

#as_uriObject

Render as Iglu URI (with ‘iglu:`)



46
47
48
# File 'lib/iglu-client/core.rb', line 46

def as_uri
  "iglu:#{as_path}"
end