Class: Microstation::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/microstation/wrap.rb

Direct Known Subclasses

Tag, Text, TextNode

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ole) ⇒ Element

Returns a new instance of Element.



132
133
134
135
# File 'lib/microstation/wrap.rb', line 132

def initialize(ole)
  @ole_obj = ole
  @original = ole_value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/microstation/wrap.rb', line 171

def method_missing(meth,*args,&block)
  if meth.to_s =~ /^[A-Z]/
    result = ole_obj.send(meth,*args,&block)
    Element.convert_item(result)
  else
    super(meth,*args,&block)
  end
end

Instance Attribute Details

#ole_objObject (readonly)

Returns the value of attribute ole_obj.



130
131
132
# File 'lib/microstation/wrap.rb', line 130

def ole_obj
  @ole_obj
end

Class Method Details

.convert_item(item) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/microstation/wrap.rb', line 111

def self.convert_item(item)
  return item unless item.class == WIN32OLE
  case item.Type
  when Microstation::MSD::MsdElementTypeText
    Microstation::Text.new(item)
  when Microstation::MSD::MsdElementTypeTextNode
    Microstation::TextNode.new(item)
  when Microstation::MSD::MsdElementTypeTag
    Microstation::Tag.new(item)
  else
    new(item)
  end
end

.ole_object?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/microstation/wrap.rb', line 125

def self.ole_object?
  ole.class == WIN32OLE
end

Instance Method Details

#_update(value) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/microstation/wrap.rb', line 180

def _update(value)
  oldvalue = @original
  return if value == oldvalue
  begin
    update_ole(value)
    @ole_obj.Redraw Microstation::MSD::MsdDrawingModeNormal
    @ole_obj.Rewrite
    @original = value
  rescue
    _update(oldvalue)
  end
end

#has_tags?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/microstation/wrap.rb', line 151

def has_tags?
  ole_obj.HasAnyTags
end

#microstation_idObject



159
160
161
# File 'lib/microstation/wrap.rb', line 159

def microstation_id
  ole_obj.Id || ole_obj.ID64
end

#microstation_typeObject



167
168
169
# File 'lib/microstation/wrap.rb', line 167

def microstation_type
  Type
end

#ole_valueObject



140
141
# File 'lib/microstation/wrap.rb', line 140

def ole_value
end

#text?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/microstation/wrap.rb', line 143

def text?
  ole_obj.Type == Microstation::MSD::MsdElementTypeText
end

#text_node?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/microstation/wrap.rb', line 147

def text_node?
  ole_obj.Type  == Microstation::MSD::MsdElementTypeTextNode
end

#textual?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/microstation/wrap.rb', line 155

def textual?
  text? || text_node?
end

#TypeObject



163
164
165
# File 'lib/microstation/wrap.rb', line 163

def Type
  ole_obj.Type
end

#update_ole(value) ⇒ Object



137
138
# File 'lib/microstation/wrap.rb', line 137

def update_ole(value)
end