Class: Autocad::Block

Inherits:
Element show all
Defined in:
lib/autocad/block.rb

Instance Attribute Summary

Attributes inherited from Element

#acad_type, #app, #ole_obj, #original

Instance Method Summary collapse

Methods inherited from Element

#[], #app_ole_obj, #clone, convert_item, #delete, #do_update, #each_complex, #get_property_handler, #in_cell?, #initialize, #method_missing, #move, #move_ole, #move_x, #move_y, #ole_cell, ole_object?, #property_handler, #read_ole, #redraw, #update, #updated?, #write_ole

Methods included from ElementTrait

#autocad_type, #block_reference?, #bounds, #cell?, #def, #drawing, #explode, #graphical?, #has_tags?, #highlight, #id_from_record, #line?, #model, #parent, #pviewport?, #select, #text?, #to_ole, #visible?

Constructor Details

This class inherits a constructor from Autocad::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Autocad::Element

Instance Method Details

#attribute_hashObject



40
41
42
43
44
# File 'lib/autocad/block.rb', line 40

def attribute_hash
  attributes.each.with_object({}) do |a, h|
    h[a.key] = a.value
  end
end

#attributesObject



60
61
62
63
64
65
66
67
# File 'lib/autocad/block.rb', line 60

def attributes
  return [] unless attributes?

  els = @ole_obj.GetAttributes
  return [] if els.empty?

  Attributes.new(self, els.map { |e| Attribute.new(e, app) })
end

#attributes?Boolean

:bool

Returns:

  • (Boolean)


20
21
22
# File 'lib/autocad/block.rb', line 20

def attributes? #:bool
  @ole_obj.HasAttributes
end

#block?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/autocad/block.rb', line 16

def block? # : bool
  true
end

#block_typeObject



46
47
48
49
50
51
52
53
54
# File 'lib/autocad/block.rb', line 46

def block_type
  if xref?
    "XRef"
  elsif dynamic?
    "Dynamic"
  elsif layout?
    "Layout"
  end
end

#dynamic?Boolean

:bool

Returns:

  • (Boolean)


36
37
38
# File 'lib/autocad/block.rb', line 36

def dynamic? #:bool
  @ole_obj.IsDynamicBlock
end

#eachObject



7
8
9
10
11
12
13
# File 'lib/autocad/block.rb', line 7

def each
  return enum_for(:each) unless block_given?

  @ole_obj.each do |ole|
    yield app.wrap(ole)
  end
end

#inspectObject



56
57
58
# File 'lib/autocad/block.rb', line 56

def inspect
  "<Block #{block_type}: '#{name}#'"
end

#layout?Boolean

:bool

Returns:

  • (Boolean)


28
29
30
# File 'lib/autocad/block.rb', line 28

def layout? #:bool
  @ole_obj.IsLayout
end

#nameObject

:String



24
25
26
# File 'lib/autocad/block.rb', line 24

def name #:String
  @ole_obj.Name
end

#xref?Boolean

:bool

Returns:

  • (Boolean)


32
33
34
# File 'lib/autocad/block.rb', line 32

def xref? #:bool
  @ole_obj.IsXRef
end