Class: MODL::Parser::MODLClass
- Inherits:
-
Object
- Object
- MODL::Parser::MODLClass
- Defined in:
- lib/modl/parser/modl_class.rb
Overview
Represents a *class defined, or loaded by, a MODL document.
Instance Attribute Summary collapse
-
#allow ⇒ Object
Returns the value of attribute allow.
-
#assign ⇒ Object
Returns the value of attribute assign.
-
#content ⇒ Object
Returns the value of attribute content.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#superclass ⇒ Object
Returns the value of attribute superclass.
Instance Method Summary collapse
-
#initialize ⇒ MODLClass
constructor
A new instance of MODLClass.
-
#keylist_of_length(len) ⇒ Object
Find a keylist of the right length from the *assign array of arrays.
- #merge_content(new_value) ⇒ Object
- #name_or_id ⇒ Object
Constructor Details
#initialize ⇒ MODLClass
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
#allow ⇒ Object
Returns the value of attribute allow.
10 11 12 |
# File 'lib/modl/parser/modl_class.rb', line 10 def allow @allow end |
#assign ⇒ Object
Returns the value of attribute assign.
8 9 10 |
# File 'lib/modl/parser/modl_class.rb', line 8 def assign @assign end |
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/modl/parser/modl_class.rb', line 9 def content @content end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/modl/parser/modl_class.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/modl/parser/modl_class.rb', line 6 def name @name end |
#superclass ⇒ Object
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.
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_id ⇒ Object
34 35 36 |
# File 'lib/modl/parser/modl_class.rb', line 34 def name_or_id @name.nil? ? @id : @name end |