Class: Meta::Data
- Inherits:
-
Object
show all
- Defined in:
- lib/meta.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, metadata = {}) ⇒ Data
Returns a new instance of Data.
6
7
8
9
10
|
# File 'lib/meta.rb', line 6
def initialize(name, metadata={})
@metadata={}
@metadata[:name]=name
@metadata.merge! metadata
end
|
Instance Attribute Details
Returns the value of attribute metadata.
4
5
6
|
# File 'lib/meta.rb', line 4
def metadata
@metadata
end
|
Class Method Details
.json_create(o) ⇒ Object
52
53
54
|
# File 'lib/meta.rb', line 52
def self.json_create(o)
me = new(o["name"], o["metadata"])
end
|
Instance Method Details
#==(other) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/meta.rb', line 20
def ==(other)
if self.name==other.name && self.metadata==other.metadata
true
else
false
end
end
|
#[](tag) ⇒ Object
39
40
41
|
# File 'lib/meta.rb', line 39
def [](tag)
metadata[tag]
end
|
#has_tag?(tag) ⇒ Boolean
28
29
30
|
# File 'lib/meta.rb', line 28
def has_tag?(tag)
metadata.key? tag
end
|
#has_value?(val) ⇒ Boolean
32
33
34
35
36
37
|
# File 'lib/meta.rb', line 32
def has_value?(val)
metadata.each_pair do |tag, value|
return true if value == val
end
return false
end
|
#name ⇒ Object
12
13
14
|
# File 'lib/meta.rb', line 12
def name
@metadata[:name]
end
|
#name=(val) ⇒ Object
16
17
18
|
# File 'lib/meta.rb', line 16
def name=(val)
@metadata[:name]=val
end
|
#to_json(*a) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/meta.rb', line 44
def to_json(*a)
{
"json_class" => self.class.name,
"name" => name,
"metadata" => metadata
}.to_json(*a)
end
|