Class: IDL::AST::Annotations
- Inherits:
-
Object
- Object
- IDL::AST::Annotations
- Defined in:
- lib/ridl/node.rb
Instance Method Summary collapse
- #<<(ann) ⇒ Object
- #[](annid) ⇒ Object
- #clear ⇒ Object
- #concat(anns) ⇒ Object
- #dup ⇒ Object
- #each(&block) ⇒ Object
- #each_for_id(annid, &block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(stack = [], index = {}) ⇒ Annotations
constructor
A new instance of Annotations.
Constructor Details
#initialize(stack = [], index = {}) ⇒ Annotations
Returns a new instance of Annotations.
52 53 54 55 |
# File 'lib/ridl/node.rb', line 52 def initialize(stack = [], index = {}) @index = index @stack = stack end |
Instance Method Details
#<<(ann) ⇒ Object
65 66 67 68 |
# File 'lib/ridl/node.rb', line 65 def <<(ann) (@index[ann.id] ||= []) << @stack.size @stack << ann end |
#[](annid) ⇒ Object
61 62 63 |
# File 'lib/ridl/node.rb', line 61 def [](annid) (@index[annid] || []).collect { |ix| @stack[ix] } end |
#clear ⇒ Object
78 79 80 81 |
# File 'lib/ridl/node.rb', line 78 def clear @index.clear @stack.clear end |
#concat(anns) ⇒ Object
83 84 85 |
# File 'lib/ridl/node.rb', line 83 def concat(anns) (anns || []).each {|_ann| self << _ann } end |
#dup ⇒ Object
87 88 89 |
# File 'lib/ridl/node.rb', line 87 def dup self.class.new(@stack.dup, @index.dup) end |
#each(&block) ⇒ Object
70 71 72 |
# File 'lib/ridl/node.rb', line 70 def each(&block) @stack.each(&block) end |
#each_for_id(annid, &block) ⇒ Object
74 75 76 |
# File 'lib/ridl/node.rb', line 74 def each_for_id(annid, &block) self[annid].each(&block) end |
#empty? ⇒ Boolean
57 58 59 |
# File 'lib/ridl/node.rb', line 57 def empty? @stack.empty? end |