Class: Igniter::Lang::Types::Descriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/lang/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, of:, dimensions: {}, metadata: {}) ⇒ Descriptor

Returns a new instance of Descriptor.



9
10
11
12
13
14
15
# File 'lib/igniter/lang/types.rb', line 9

def initialize(kind:, of:, dimensions: {}, metadata: {})
  @kind = kind.to_sym
  @of = of
  @dimensions = dimensions.transform_keys(&:to_sym).freeze
  @metadata = .transform_keys(&:to_sym).freeze
  freeze
end

Instance Attribute Details

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



7
8
9
# File 'lib/igniter/lang/types.rb', line 7

def dimensions
  @dimensions
end

#kindObject (readonly)

Returns the value of attribute kind.



7
8
9
# File 'lib/igniter/lang/types.rb', line 7

def kind
  @kind
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/igniter/lang/types.rb', line 7

def 
  @metadata
end

#ofObject (readonly)

Returns the value of attribute of.



7
8
9
# File 'lib/igniter/lang/types.rb', line 7

def of
  @of
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



30
31
32
# File 'lib/igniter/lang/types.rb', line 30

def ==(other)
  other.is_a?(self.class) && to_h == other.to_h
end

#hashObject



35
36
37
# File 'lib/igniter/lang/types.rb', line 35

def hash
  to_h.hash
end

#inspectObject



26
27
28
# File 'lib/igniter/lang/types.rb', line 26

def inspect
  "#<#{self.class.name} #{to_h.inspect}>"
end

#to_hObject



17
18
19
20
21
22
23
24
# File 'lib/igniter/lang/types.rb', line 17

def to_h
  {
    kind: kind,
    of: serialize_type(of),
    dimensions: serialize_dimensions,
    metadata: 
  }
end