Class: Meta::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/meta.rb

Direct Known Subclasses

Bio::Ngs::Illumina::MetaReads, Pool

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[:name]=name
  @metadata.merge! 
end

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/meta.rb', line 4

def 
  @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.==other.
    true
  else
    false
  end
end

#[](tag) ⇒ Object



39
40
41
# File 'lib/meta.rb', line 39

def [](tag)
  [tag]
end

#has_tag?(tag) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/meta.rb', line 28

def has_tag?(tag)
  .key? tag
end

#has_value?(val) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/meta.rb', line 32

def has_value?(val)
  .each_pair do |tag, value|
    return true if value == val
  end
  return false
end

#nameObject



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"    => 
  }.to_json(*a)
end