Class: Interscript::Node::MetaData

Inherits:
Interscript::Node show all
Defined in:
lib/interscript/node/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ MetaData

Returns a new instance of MetaData.



3
4
5
# File 'lib/interscript/node/metadata.rb', line 3

def initialize data={}
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/interscript/node/metadata.rb', line 2

def data
  @data
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/interscript/node/metadata.rb', line 20

def ==(other)
  super && self.data == other.data
end

#[](k) ⇒ Object



10
11
12
# File 'lib/interscript/node/metadata.rb', line 10

def [](k)
  @data[k]
end

#[]=(k, v) ⇒ Object



7
8
9
# File 'lib/interscript/node/metadata.rb', line 7

def []=(k,v)
  @data[k] = v
end

#reverseObject



14
15
16
17
18
# File 'lib/interscript/node/metadata.rb', line 14

def reverse
  self.class.new(data.dup, **{}).tap do |rmd|
    rmd[:source_script], rmd[:destination_script] = rmd[:destination_script], rmd[:source_script]
  end
end

#to_hashObject



24
25
26
27
# File 'lib/interscript/node/metadata.rb', line 24

def to_hash
  {:class => self.class.to_s,
    :data => @data}
end