Class: Scale::Types::Metadata
- Inherits:
-
Object
- Object
- Scale::Types::Metadata
show all
- Includes:
- Base
- Defined in:
- lib/metadata/metadata.rb
Instance Attribute Summary collapse
Attributes included from Base
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#==, included, #initialize, #to_human
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
5
6
7
|
# File 'lib/metadata/metadata.rb', line 5
def version
@version
end
|
Class Method Details
.decode(scale_bytes) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/metadata/metadata.rb', line 6
def self.decode(scale_bytes)
bytes = scale_bytes.get_next_bytes(4)
if bytes.bytes_to_utf8 == "meta"
version_enum = {
"type" => "enum",
"value_list" => %w[MetadataV0 MetadataV1 MetadataV2 MetadataV3 MetadataV4 MetadataV5 MetadataV6 MetadataV7 MetadataV8 MetadataV9 MetadataV10 MetadataV11 MetadataV12 MetadataV13]
}
metadata_version = Scale::Types.get(version_enum).decode(scale_bytes).value
metadata = Metadata.new "Scale::Types::#{metadata_version}".constantize2.decode(scale_bytes)
metadata.version = metadata_version[9..].to_i
else
scale_bytes.reset_offset
metadata_v0 = Scale::Types::MetadataV0.decode(scale_bytes)
metadata = Metadata.new metadata_v0
metadata.version = 0
end
metadata
end
|
Instance Method Details
#get_module(module_name) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/metadata/metadata.rb', line 25
def get_module(module_name)
modules = self.value.value[:metadata][:modules]
modules.each do |m|
if m[:name].downcase == module_name.downcase
return m
end
end
end
|
#get_module_call(module_name, call_name) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/metadata/metadata.rb', line 34
def get_module_call(module_name, call_name)
the_module = get_module(module_name)
the_module[:calls].each do |call|
if call[:name].downcase == call_name.downcase
return call
end
end
end
|
#get_module_storage(module_name, storage_name) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/metadata/metadata.rb', line 43
def get_module_storage(module_name, storage_name)
the_module = get_module(module_name)
if the_module[:storage].class == Array
storages = the_module[:storage]
else
storages = the_module[:storage][:items]
end
storages.find {|storage| storage[:name] == storage_name}
end
|