Class: MODL::Parser::MODLClass

Inherits:
Object
  • Object
show all
Defined in:
lib/modl/parser/modl_class.rb

Overview

Represents a *class defined, or loaded by, a MODL document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMODLClass

Returns a new instance of MODLClass.



12
13
14
# File 'lib/modl/parser/modl_class.rb', line 12

def initialize
  @content = {}
end

Instance Attribute Details

#allowObject

Returns the value of attribute allow.



10
11
12
# File 'lib/modl/parser/modl_class.rb', line 10

def allow
  @allow
end

#assignObject

Returns the value of attribute assign.



8
9
10
# File 'lib/modl/parser/modl_class.rb', line 8

def assign
  @assign
end

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/modl/parser/modl_class.rb', line 9

def content
  @content
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/modl/parser/modl_class.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/modl/parser/modl_class.rb', line 6

def name
  @name
end

#superclassObject

Returns the value of attribute superclass.



7
8
9
# File 'lib/modl/parser/modl_class.rb', line 7

def superclass
  @superclass
end

Instance Method Details

#keylist_of_length(len) ⇒ Object

Find a keylist of the right length from the *assign array of arrays.

Raises:



17
18
19
20
21
22
23
24
25
# File 'lib/modl/parser/modl_class.rb', line 17

def keylist_of_length(len)
  return [] if @assign.nil?

  @assign.each do |kl|
    return kl if kl.length == len
  end
  raise InterpreterError,
        'No key list of the correct length in class ' + @id + ' - looking for one of length ' + len.to_s
end

#merge_content(new_value) ⇒ Object



27
28
29
30
31
32
# File 'lib/modl/parser/modl_class.rb', line 27

def merge_content(new_value)
  @content.each do |k, v|
    new_value[k] = v.extract_hash
  end
  new_value
end

#name_or_idObject



34
35
36
# File 'lib/modl/parser/modl_class.rb', line 34

def name_or_id
  @name.nil? ? @id : @name
end