Class: Microstation::Text

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

Instance Attribute Summary

Attributes inherited from Element

#ole_obj

Instance Method Summary collapse

Methods inherited from Element

#Type, convert_item, #has_tags?, #microstation_id, #microstation_type, ole_object?, #ole_value, #text?, #text_node?, #textual?, #update_ole

Constructor Details

#initialize(ole) ⇒ Text

Returns a new instance of Text.



5
6
7
8
# File 'lib/microstation/text.rb', line 5

def initialize(ole)
  @ole_obj = ole
  @original_text = @ole_obj.Text
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



36
37
38
39
40
41
# File 'lib/microstation/text.rb', line 36

def method_missing(meth,*args,&block)
  dup = @original_text.dup
    result = dup.send(meth,*args, &block)
    _update(dup) unless dup == @original_text
  result
end

Instance Method Details

#_update(text) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/microstation/text.rb', line 44

def _update(text)
  @ole_obj.Text = text
  @original_text = text
  @ole_obj.Redraw Microstation::MSD::MsdDrawingModeNormal
  @ole_obj.Rewrite
  @original_text = text
end

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



25
26
27
28
29
30
31
32
33
34
# File 'lib/microstation/text.rb', line 25

def method_missing2(meth,*args, &block)
  if meth =~ /^[A-Z]/
    @ole_obj.send(meth,*args)
  else
    dup = @original_text.dup
    result = dup.send(meth,*args, &block)
    _update(dup) unless dup == @original_text
    result
  end
end

#to_sObject

def text_node?

false

end



21
22
23
# File 'lib/microstation/text.rb', line 21

def to_s
  @original_text.to_s
end