class Thinreports::Core::Shape::TextBlock::Internal

Attributes

style[R]

Public Class Methods

new(*args) click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 12
def initialize(*args)
  super(*args)

  @reference = nil
  @formatter = nil

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

Public Instance Methods

format_enabled(enabled) click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 48
def format_enabled(enabled)
  states[:format_enabled] = enabled
end
format_enabled?() click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 52
def format_enabled?
  if states.key?(:format_enabled)
    states[:format_enabled]
  else
    !blank_value?(format.format_base) || format.has_format?
  end
end
read_value() click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 22
def read_value
  if format.has_reference?
    @reference ||= parent.item(format.ref_id)
    @reference.value
  else
    super
  end
end
real_value() click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 40
def real_value
  if format_enabled?
    formatter.apply(read_value)
  else
    super
  end
end
type_of?(type_name) click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 60
def type_of?(type_name)
  type_name == TextBlock::TYPE_NAME || super
end
write_value(val) click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 31
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

Private Instance Methods

formatter() click to toggle source
# File lib/thinreports/core/shape/text_block/internal.rb, line 66
def formatter
  @formatter ||= TextBlock::Formatter.setup(format)
end