Class: Microstation::TextNode
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Element
#Type, convert_item, #has_tags?, #microstation_id, #microstation_type, ole_object?, #ole_value, #text_node?, #textual?
Constructor Details
#initialize(ole) ⇒ TextNode
Returns a new instance of TextNode.
7
8
9
10
|
# File 'lib/microstation/text_node.rb', line 7
def initialize(ole)
@ole_obj = ole
@original_text = ole_to_ruby(ole)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/microstation/text_node.rb', line 53
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 Attribute Details
#ole_obj ⇒ Object
Returns the value of attribute ole_obj.
5
6
7
|
# File 'lib/microstation/text_node.rb', line 5
def ole_obj
@ole_obj
end
|
#original_text ⇒ Object
Returns the value of attribute original_text.
5
6
7
|
# File 'lib/microstation/text_node.rb', line 5
def original_text
@original_text
end
|
Instance Method Details
#_update(text) ⇒ Object
35
36
37
38
|
# File 'lib/microstation/text_node.rb', line 35
def _update(text)
update_ole(text)
@original_text = text
end
|
#empty? ⇒ Boolean
12
13
14
|
# File 'lib/microstation/text_node.rb', line 12
def empty?
ole_obj.TextLinesCount == 0
end
|
#method_missing2(meth, *args, &block) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/microstation/text_node.rb', line 61
def method_missing2(meth,*args,&block)
if meth.to_s =~ /^[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
|
#ole_to_ruby(ole) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/microstation/text_node.rb', line 25
def ole_to_ruby(ole)
count = ole.TextLinesCount
str_array = []
1.upto(count) do |i|
str_array << ole.TextLine(i)
end
str_array.join("\n")
end
|
#size ⇒ Object
20
21
22
|
# File 'lib/microstation/text_node.rb', line 20
def size
ole_obj.TextLinesCount
end
|
#text? ⇒ Boolean
16
17
18
|
# File 'lib/microstation/text_node.rb', line 16
def text?
false
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/microstation/text_node.rb', line 49
def to_s
@original_text.to_s
end
|
#update_ole(text) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/microstation/text_node.rb', line 40
def update_ole(text)
ole_obj.DeleteAllTextLines
text.each_line do |line|
ole_obj.AddTextLine(line)
end
ole_obj.Redraw Microstation::MSD::MsdDrawingModeNormal
ole_obj.Rewrite
end
|