Class: Microstation::TagSets
- Inherits:
-
Object
- Object
- Microstation::TagSets
- Includes:
- Enumerable
- Defined in:
- lib/microstation/tag_set.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #create(name) {|definer| ... } ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #find(name) ⇒ Object
- #init_ts ⇒ Object
-
#initialize(ole) ⇒ TagSets
constructor
A new instance of TagSets.
- #last ⇒ Object
- #remove(name) ⇒ Object
- #reset ⇒ Object
- #size ⇒ Object
- #tagsets ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ole) ⇒ TagSets
Returns a new instance of TagSets.
9 10 11 |
# File 'lib/microstation/tag_set.rb', line 9 def initialize(ole) @ole_obj = ole end |
Instance Method Details
#[](name) ⇒ Object
48 49 50 |
# File 'lib/microstation/tag_set.rb', line 48 def [](name) find(name) end |
#create(name) {|definer| ... } ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/microstation/tag_set.rb', line 66 def create(name) raise if self[name] ole = @ole_obj.add(name) definer = Definer.new(ole) yield definer if block_given? @tagsets = init_ts ts = self[name] raise if ts.nil? definer = nil ts end |
#each ⇒ Object
33 34 35 36 37 |
# File 'lib/microstation/tag_set.rb', line 33 def each .each do |obj| yield obj end end |
#empty? ⇒ Boolean
62 63 64 |
# File 'lib/microstation/tag_set.rb', line 62 def empty? .empty? end |
#find(name) ⇒ Object
39 40 41 42 |
# File 'lib/microstation/tag_set.rb', line 39 def find(name) return nil if empty? .find{|ts| ts.name == name} end |
#init_ts ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/microstation/tag_set.rb', line 13 def init_ts result = [] @ole_obj.each do |ts| result << TagSet.new(ts) end result end |
#last ⇒ Object
44 45 46 |
# File 'lib/microstation/tag_set.rb', line 44 def last [-1] end |
#remove(name) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/microstation/tag_set.rb', line 52 def remove(name) ts = find(name) if ts @ole_obj.Remove(name) rescue nil ts.close ts = nil end @tagsets = init_ts end |
#reset ⇒ Object
25 26 27 |
# File 'lib/microstation/tag_set.rb', line 25 def reset @tagsets = nil end |
#size ⇒ Object
78 79 80 |
# File 'lib/microstation/tag_set.rb', line 78 def size .size end |
#tagsets ⇒ Object
29 30 31 |
# File 'lib/microstation/tag_set.rb', line 29 def @tagsets ||= init_ts end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/microstation/tag_set.rb', line 21 def to_s "Tagsets: #{.to_s}" end |