Class: ShafClient::Alps::Descriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf_client/alps/descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, **kwargs) ⇒ Descriptor

Returns a new instance of Descriptor.



8
9
10
11
12
13
14
15
# File 'lib/shaf_client/alps/descriptor.rb', line 8

def initialize(id:, **kwargs)
  @id   = id.to_sym
  @href = kwargs[:href]
  @name = kwargs[:name]
  @type = kwargs[:type]
  @doc  = kwargs[:doc]
  @ext  = parse_extentions(kwargs[:ext])
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def doc
  @doc
end

#extObject (readonly) Also known as: extensions

Returns the value of attribute ext.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def ext
  @ext
end

#hrefObject (readonly)

Returns the value of attribute href.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def href
  @href
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/shaf_client/alps/descriptor.rb', line 6

def type
  @type
end

Instance Method Details

#extension(id) ⇒ Object



46
47
48
# File 'lib/shaf_client/alps/descriptor.rb', line 46

def extension(id)
  extensions.find { |ext| ext.id == id.to_sym }
end

#idempotent?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/shaf_client/alps/descriptor.rb', line 38

def idempotent?
  type == 'idempotent'
end

#safe?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/shaf_client/alps/descriptor.rb', line 34

def safe?
  type == 'safe'
end

#semantic?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/shaf_client/alps/descriptor.rb', line 30

def semantic?
  type == 'semantic'
end

#to_hObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/shaf_client/alps/descriptor.rb', line 19

def to_h
  {
    id: id,
    href: href,
    name: name,
    type: type,
    doc: doc,
    ext: extensions.map(&:to_h),
  }
end

#unsafe?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/shaf_client/alps/descriptor.rb', line 42

def unsafe?
  type == 'unsafe'
end