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(&block) ⇒ 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.
33 34 35 36 37 38 |
# File 'lib/microstation/tag_set.rb', line 33 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.
31 32 33 |
# File 'lib/microstation/tag_set.rb', line 31 def drawing @drawing end |
#ole_obj ⇒ Object (readonly)
Returns the value of attribute ole_obj.
31 32 33 |
# File 'lib/microstation/tag_set.rb', line 31 def ole_obj @ole_obj end |
Instance Method Details
#[](name) ⇒ Object
79 80 81 |
# File 'lib/microstation/tag_set.rb', line 79 def [](name) find(name) end |
#create(name) {|ts| ... } ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/microstation/tag_set.rb', line 101 def create(name) raise if self[name] ole = begin @ole_obj.add(name) rescue binding.pry end # 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(&block) ⇒ Object
65 66 67 |
# File 'lib/microstation/tag_set.rb', line 65 def each(&block) .each(&block) end |
#empty? ⇒ Boolean
97 98 99 |
# File 'lib/microstation/tag_set.rb', line 97 def empty? .empty? end |
#find(name) ⇒ Object
69 70 71 72 73 |
# File 'lib/microstation/tag_set.rb', line 69 def find(name) return nil if empty? .detect { |ts| ts.name == name } end |
#init_ts ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/microstation/tag_set.rb', line 40 def init_ts result = [] @ole_obj.each do |ts| result << TagSet.new(drawing, ts) end result end |
#last ⇒ Object
75 76 77 |
# File 'lib/microstation/tag_set.rb', line 75 def last [-1] end |
#names ⇒ Object
57 58 59 |
# File 'lib/microstation/tag_set.rb', line 57 def names map { |ts| ts.name } end |
#remove(name) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/microstation/tag_set.rb', line 83 def remove(name) ts = find(name) if ts begin @ole_obj.Remove(name) rescue nil end ts.close ts = nil end reset end |
#reset ⇒ Object
52 53 54 55 |
# File 'lib/microstation/tag_set.rb', line 52 def reset = nil @drawing. end |
#size ⇒ Object
119 120 121 |
# File 'lib/microstation/tag_set.rb', line 119 def size .size end |
#tagsets ⇒ Object
61 62 63 |
# File 'lib/microstation/tag_set.rb', line 61 def ||= init_ts end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/microstation/tag_set.rb', line 48 def to_s "Tagsets: #{tagsets}" end |