Class: IDL::AST::Annotations
- Inherits:
-
Object
- Object
- IDL::AST::Annotations
- Defined in:
- lib/ridl/node.rb
Instance Method Summary collapse
- #<<(ann) ⇒ Object
- #[](annid) ⇒ Object
- #concat(anns) ⇒ Object
- #each(&block) ⇒ Object
- #each_for_id(annid, &block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Annotations
constructor
A new instance of Annotations.
Constructor Details
#initialize ⇒ Annotations
Returns a new instance of Annotations.
50 51 52 53 |
# File 'lib/ridl/node.rb', line 50 def initialize @index = {} @stack = [] end |
Instance Method Details
#<<(ann) ⇒ Object
63 64 65 66 |
# File 'lib/ridl/node.rb', line 63 def <<(ann) (@index[ann.id] ||= []) << @stack.size @stack << ann end |
#[](annid) ⇒ Object
59 60 61 |
# File 'lib/ridl/node.rb', line 59 def [](annid) (@index[annid] || []).collect { |ix| @stack[ix] } end |
#concat(anns) ⇒ Object
76 77 78 |
# File 'lib/ridl/node.rb', line 76 def concat(anns) anns.each { |_ann| self << _ann } if anns end |
#each(&block) ⇒ Object
68 69 70 |
# File 'lib/ridl/node.rb', line 68 def each(&block) @stack.each(&block) end |
#each_for_id(annid, &block) ⇒ Object
72 73 74 |
# File 'lib/ridl/node.rb', line 72 def each_for_id(annid, &block) self[annid].each(&block) end |
#empty? ⇒ Boolean
55 56 57 |
# File 'lib/ridl/node.rb', line 55 def empty? @stack.empty? end |