Class: XDry::OClass
- Inherits:
-
Object
- Object
- XDry::OClass
- Defined in:
- lib/xdry/parsing/model.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#field_defs ⇒ Object
readonly
Returns the value of attribute field_defs.
-
#implementations ⇒ Object
readonly
Returns the value of attribute implementations.
-
#interfaces ⇒ Object
readonly
Returns the value of attribute interfaces.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#oglobal ⇒ Object
readonly
Returns the value of attribute oglobal.
Instance Method Summary collapse
- #<<(node) ⇒ Object
- #add_implementation(child) ⇒ Object
- #add_interface(child) ⇒ Object
- #find_attribute(name) ⇒ Object
- #find_method(selector) ⇒ Object
- #has_method_impl?(selector) ⇒ Boolean
-
#initialize(oglobal, name) ⇒ OClass
constructor
A new instance of OClass.
- #main_implementation ⇒ Object
- #main_interface ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(oglobal, name) ⇒ OClass
Returns a new instance of OClass.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/xdry/parsing/model.rb', line 40 def initialize oglobal, name @oglobal, @name = oglobal, name @names_to_attributes = {} @attributes = [] @selectors_to_methods = {} @methods = [] @field_defs = [] @property_defs = [] @interfaces = [] @implementations = [] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
36 37 38 |
# File 'lib/xdry/parsing/model.rb', line 36 def attributes @attributes end |
#field_defs ⇒ Object (readonly)
Returns the value of attribute field_defs.
36 37 38 |
# File 'lib/xdry/parsing/model.rb', line 36 def field_defs @field_defs end |
#implementations ⇒ Object (readonly)
Returns the value of attribute implementations.
38 39 40 |
# File 'lib/xdry/parsing/model.rb', line 38 def implementations @implementations end |
#interfaces ⇒ Object (readonly)
Returns the value of attribute interfaces.
37 38 39 |
# File 'lib/xdry/parsing/model.rb', line 37 def interfaces @interfaces end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
36 37 38 |
# File 'lib/xdry/parsing/model.rb', line 36 def methods @methods end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/xdry/parsing/model.rb', line 36 def name @name end |
#oglobal ⇒ Object (readonly)
Returns the value of attribute oglobal.
35 36 37 |
# File 'lib/xdry/parsing/model.rb', line 35 def oglobal @oglobal end |
Instance Method Details
#<<(node) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/xdry/parsing/model.rb', line 73 def << node case node when NFieldDef @field_defs << node attr_name = node.name.gsub /^_/, '' lookup_attribute(attr_name).add_field_def! node when NPropertyDef @property_defs << node attr_name = node.name lookup_attribute(attr_name).add_property_def! node when NMethodHeader selector = node.selector lookup_method(selector).add_method_header! node when NSynthesize node.items.each do |item| lookup_attribute(item.property_name).add_synthesize! node end when SInterfaceFields node.bind(self) when SMethodImpl lookup_method(node.selector).add_method_impl! node end end |
#add_implementation(child) ⇒ Object
59 60 61 |
# File 'lib/xdry/parsing/model.rb', line 59 def add_implementation child @implementations << child.bind(self) end |
#add_interface(child) ⇒ Object
55 56 57 |
# File 'lib/xdry/parsing/model.rb', line 55 def add_interface child @interfaces << child.bind(self) end |
#find_attribute(name) ⇒ Object
101 102 103 |
# File 'lib/xdry/parsing/model.rb', line 101 def find_attribute name @names_to_attributes[name] end |
#find_method(selector) ⇒ Object
105 106 107 |
# File 'lib/xdry/parsing/model.rb', line 105 def find_method selector @selectors_to_methods[selector] end |
#has_method_impl?(selector) ⇒ Boolean
109 110 111 112 |
# File 'lib/xdry/parsing/model.rb', line 109 def has_method_impl? selector m = find_method(selector) return m && m.has_impl? end |
#main_implementation ⇒ Object
68 69 70 71 |
# File 'lib/xdry/parsing/model.rb', line 68 def main_implementation # FIXME @implementations.first end |
#main_interface ⇒ Object
63 64 65 66 |
# File 'lib/xdry/parsing/model.rb', line 63 def main_interface # FIXME @interfaces.first end |
#to_s ⇒ Object
97 98 99 |
# File 'lib/xdry/parsing/model.rb', line 97 def to_s "class #{name}" end |