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.
-
#expect ⇒ Object
Returns the value of attribute expect.
-
#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.
37 38 39 |
# File 'lib/modl/parser/modl_class.rb', line 37 def initialize @content = {} end |
Instance Attribute Details
#allow ⇒ Object
Returns the value of attribute allow.
34 35 36 |
# File 'lib/modl/parser/modl_class.rb', line 34 def allow @allow end |
#assign ⇒ Object
Returns the value of attribute assign.
32 33 34 |
# File 'lib/modl/parser/modl_class.rb', line 32 def assign @assign end |
#content ⇒ Object
Returns the value of attribute content.
33 34 35 |
# File 'lib/modl/parser/modl_class.rb', line 33 def content @content end |
#expect ⇒ Object
Returns the value of attribute expect.
35 36 37 |
# File 'lib/modl/parser/modl_class.rb', line 35 def expect @expect end |
#id ⇒ Object
Returns the value of attribute id.
29 30 31 |
# File 'lib/modl/parser/modl_class.rb', line 29 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'lib/modl/parser/modl_class.rb', line 30 def name @name end |
#superclass ⇒ Object
Returns the value of attribute superclass.
31 32 33 |
# File 'lib/modl/parser/modl_class.rb', line 31 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.
42 43 44 45 46 47 48 49 50 |
# File 'lib/modl/parser/modl_class.rb', line 42 def keylist_of_length(len) return nil if @assign.nil? @assign.each do |kl| return kl if kl.length == len end raise InterpreterError, 'Interpreter Error: No key list of the correct length in class ' + @id + ' - looking for one of length ' + len.to_s end |
#merge_content(new_value) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/modl/parser/modl_class.rb', line 52 def merge_content(new_value) @content.each do |k, v| new_value[k] = v.extract_hash end new_value end |
#name_or_id ⇒ Object
59 60 61 |
# File 'lib/modl/parser/modl_class.rb', line 59 def name_or_id @name.nil? ? @id : @name end |