Class: Microstation::TagSets
- Inherits:
-
Object
- Object
- Microstation::TagSets
- Includes:
- Enumerable
- Defined in:
- lib/microstation/tag_set.rb
Instance Attribute Summary collapse
-
#drawing ⇒ Object
readonly
Returns the value of attribute drawing.
-
#ole_obj ⇒ Object
readonly
Returns the value of attribute ole_obj.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #create(name) {|ts| ... } ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #find(name) ⇒ Object
- #init_ts ⇒ Object
-
#initialize(drawing, ole) ⇒ TagSets
constructor
A new instance of TagSets.
- #last ⇒ Object
- #names ⇒ Object
- #remove(name) ⇒ Object
- #reset ⇒ Object
- #size ⇒ Object
- #tagsets ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(drawing, ole) ⇒ TagSets
Returns a new instance of TagSets.
35 36 37 38 39 |
# File 'lib/microstation/tag_set.rb', line 35 def initialize(drawing,ole) raise if ole == nil @drawing = drawing @ole_obj = ole end |
Instance Attribute Details
#drawing ⇒ Object (readonly)
Returns the value of attribute drawing.
33 34 35 |
# File 'lib/microstation/tag_set.rb', line 33 def drawing @drawing end |
#ole_obj ⇒ Object (readonly)
Returns the value of attribute ole_obj.
33 34 35 |
# File 'lib/microstation/tag_set.rb', line 33 def ole_obj @ole_obj end |
Instance Method Details
#[](name) ⇒ Object
82 83 84 |
# File 'lib/microstation/tag_set.rb', line 82 def [](name) find(name) end |
#create(name) {|ts| ... } ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/microstation/tag_set.rb', line 100 def create(name) raise if self[name] ole = @ole_obj.add(name) rescue binding.pry # ts = Tagset.new(ole) # yield definer if block_given? reset ts = self[name] raise if ts.nil? yield ts if block_given? ts end |
#each ⇒ Object
67 68 69 70 71 |
# File 'lib/microstation/tag_set.rb', line 67 def each .each do |obj| yield obj end end |
#empty? ⇒ Boolean
96 97 98 |
# File 'lib/microstation/tag_set.rb', line 96 def empty? .empty? end |
#find(name) ⇒ Object
73 74 75 76 |
# File 'lib/microstation/tag_set.rb', line 73 def find(name) return nil if empty? .detect{|ts| ts.name == name} end |
#init_ts ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/microstation/tag_set.rb', line 41 def init_ts result = [] @ole_obj.each do |ts| result << TagSet.new(drawing,ts) end result end |
#last ⇒ Object
78 79 80 |
# File 'lib/microstation/tag_set.rb', line 78 def last [-1] end |
#names ⇒ Object
58 59 60 |
# File 'lib/microstation/tag_set.rb', line 58 def names self.map{|ts| ts.name} end |
#remove(name) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/microstation/tag_set.rb', line 86 def remove(name) ts = find(name) if ts @ole_obj.Remove(name) rescue nil ts.close ts = nil end reset end |
#reset ⇒ Object
53 54 55 56 |
# File 'lib/microstation/tag_set.rb', line 53 def reset = nil @drawing. end |
#size ⇒ Object
113 114 115 |
# File 'lib/microstation/tag_set.rb', line 113 def size .size end |
#tagsets ⇒ Object
63 64 65 |
# File 'lib/microstation/tag_set.rb', line 63 def ||= init_ts end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/microstation/tag_set.rb', line 49 def to_s "Tagsets: #{tagsets.to_s}" end |