Class: Thinreports::BasicReport::Core::Shape::Manager::Internal
- Inherits:
-
Object
- Object
- Thinreports::BasicReport::Core::Shape::Manager::Internal
- Includes:
- Utils
- Defined in:
- lib/thinreports/basic_report/core/shape/manager/internal.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#lists ⇒ Object
readonly
Returns the value of attribute lists.
-
#shapes ⇒ Object
readonly
Returns the value of attribute shapes.
Instance Method Summary collapse
- #final_shape(id) ⇒ Thinreports::BasicReport::Core::Shape::Base::Interface?
- #find_format(id) ⇒ Thinreports::BasicReport::Core::Shape::Basic::Format
- #find_item(id, limit = {}) ⇒ Object
- #init_item(format) ⇒ Object
-
#initialize(format, init_item_handler) ⇒ Internal
constructor
A new instance of Internal.
- #valid_type?(type, limit = {}) ⇒ Booldan
Methods included from Utils
#blank_value?, #call_block_in, #deep_copy, included
Constructor Details
#initialize(format, init_item_handler) ⇒ Internal
Returns a new instance of Internal.
17 18 19 20 21 22 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 17 def initialize(format, init_item_handler) @format = format @shapes = {} @lists = {} @init_item_handler = init_item_handler end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
11 12 13 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 11 def format @format end |
#lists ⇒ Object (readonly)
Returns the value of attribute lists.
13 14 15 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 13 def lists @lists end |
#shapes ⇒ Object (readonly)
Returns the value of attribute shapes.
12 13 14 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 12 def shapes @shapes end |
Instance Method Details
#final_shape(id) ⇒ Thinreports::BasicReport::Core::Shape::Base::Interface?
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 51 def final_shape(id) shape = shapes[id] # When shape was found in registry. if shape return nil unless shape.visible? # In the case of TextBlock or ImageBlock. if shape.internal.type_of?(:block) blank_value?(shape.internal.real_value) ? nil : shape else shape end # When shape was not found in registry. elsif format.has_shape?(id) shape_format = find_format(id) return nil unless shape_format.display? case shape_format.type # In the case of TextBlock. when TextBlock::TYPE_NAME return nil if !shape_format.has_reference? && blank_value?(shape_format.value) init_item(shape_format) # In the case of ImageBlock, Return the nil constantly. when ImageBlock::TYPE_NAME nil else init_item(shape_format) end end end |
#find_format(id) ⇒ Thinreports::BasicReport::Core::Shape::Basic::Format
26 27 28 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 26 def find_format(id) format.find_shape(id.to_sym) end |
#find_item(id, limit = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 32 def find_item(id, limit = {}) id = id.to_sym if shapes.key?(id) shape = shapes[id] valid_type?(shape.type, limit) ? shape : nil elsif find_format(id) shape_format = find_format(id) return nil unless valid_type?(shape_format.type, limit) shape = init_item(shape_format) shapes[id] = shape shape end end |
#init_item(format) ⇒ Object
84 85 86 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 84 def init_item(format) @init_item_handler.call(format) end |
#valid_type?(type, limit = {}) ⇒ Booldan
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/thinreports/basic_report/core/shape/manager/internal.rb', line 93 def valid_type?(type, limit = {}) return true if limit.empty? if limit[:only] type == limit[:only] elsif limit[:except] type != limit[:except] else raise ArgumentError end end |