Class: Mead::Container

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Container

Returns a new instance of Container.



5
6
7
8
9
10
# File 'lib/mead/container.rb', line 5

def initialize(options={})
  @type = options[:type]
  @label = options[:label]
  @identifier = options[:identifier]
  @text = options[:text]
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



3
4
5
# File 'lib/mead/container.rb', line 3

def identifier
  @identifier
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/mead/container.rb', line 3

def label
  @label
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/mead/container.rb', line 3

def text
  @text
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/mead/container.rb', line 3

def type
  @type
end

Instance Method Details

#==(another_container) ⇒ Object



12
13
14
15
16
17
# File 'lib/mead/container.rb', line 12

def ==(another_container)
  self.identifier == another_container.identifier and
  self.type == another_container.type and
  self.label == another_container.label and
  self.text == another_container.text
end

#to_json(*a) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/mead/container.rb', line 19

def to_json(*a)
  h = {
    'json_class'   => self.class.name
  }
  self.instance_variables.each do |var|
    h[var.sub('@','').to_sym] = self.send(var.sub('@','').to_sym)
  end
  h.to_json(*a)
end