Class: Thinreports::BasicReport::Core::Shape::TextBlock::Internal

Inherits:
Basic::BlockInternal show all
Defined in:
lib/thinreports/basic_report/core/shape/text_block/internal.rb

Instance Attribute Summary collapse

Attributes inherited from Base::Internal

#format, #parent, #states

Instance Method Summary collapse

Methods inherited from Basic::Internal

#identifier

Methods inherited from Base::Internal

#copy

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Constructor Details

#initialize(*args) ⇒ Internal

Returns a new instance of Internal.



13
14
15
16
17
18
19
20
21
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 13

def initialize(*args)
  super(*args)

  @reference = nil
  @formatter = nil

  @style = Style::Text.new(format)
  @style.accessible_styles.delete(:valign) unless multiple?
end

Instance Attribute Details

#styleObject (readonly)

Returns the value of attribute style.



11
12
13
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 11

def style
  @style
end

Instance Method Details

#format_enabled(enabled) ⇒ Object



49
50
51
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 49

def format_enabled(enabled)
  states[:format_enabled] = enabled
end

#format_enabled?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 53

def format_enabled?
  if states.key?(:format_enabled)
    states[:format_enabled]
  else
    !blank_value?(format.format_base) || format.has_format?
  end
end

#read_valueObject



23
24
25
26
27
28
29
30
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 23

def read_value
  if format.has_reference?
    @reference ||= parent.item(format.ref_id)
    @reference.value
  else
    super
  end
end

#real_valueObject



41
42
43
44
45
46
47
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 41

def real_value
  if format_enabled?
    formatter.apply(read_value)
  else
    super
  end
end

#type_of?(type_name) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 61

def type_of?(type_name)
  type_name == TextBlock::TYPE_NAME || super
end

#write_value(val) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/thinreports/basic_report/core/shape/text_block/internal.rb', line 32

def write_value(val)
  if format.has_reference?
    warn 'The set value was not saved, ' \
         "Because '#{format.id}' has reference to '#{format.ref_id}'."
  else
    super
  end
end