class Thinreports::Core::Shape::Style::Text

Public Class Methods

new(*) click to toggle source
# File lib/thinreports/core/shape/style/text.rb, line 23
def initialize(*)
  super
  initialize_font_style
end

Public Instance Methods

align() click to toggle source

@return [:left, :center, :right]

# File lib/thinreports/core/shape/style/text.rb, line 69
def align
  read_internal_style('text-align').to_sym
end
align=(align_name) click to toggle source

@param [:left, :center, :right] align_name

# File lib/thinreports/core/shape/style/text.rb, line 74
def align=(align_name)
  verify_style_value(align_name, %i[left center right],
                     'Only :left or :center, :right can be specified as align.')
  write_internal_style('text-align', align_name.to_s)
end
bold() click to toggle source

@return [Boolean]

# File lib/thinreports/core/shape/style/text.rb, line 29
def bold
  read_internal_style('font-style').include?('bold')
end
bold=(enable) click to toggle source

@param [Boolean] enable

# File lib/thinreports/core/shape/style/text.rb, line 34
def bold=(enable)
  write_font_style('bold', enable)
end
italic() click to toggle source

@return [Boolean]

# File lib/thinreports/core/shape/style/text.rb, line 39
def italic
  read_internal_style('font-style').include?('italic')
end
italic=(enable) click to toggle source

@param [Boolean] enable

# File lib/thinreports/core/shape/style/text.rb, line 44
def italic=(enable)
  write_font_style('italic', enable)
end
linethrough() click to toggle source

@return [Boolean]

# File lib/thinreports/core/shape/style/text.rb, line 59
def linethrough
  read_internal_style('font-style').include?('linethrough')
end
linethrough=(enable) click to toggle source

@param [Boolean] enable

# File lib/thinreports/core/shape/style/text.rb, line 64
def linethrough=(enable)
  write_font_style('linethrough', enable)
end
underline() click to toggle source

@return [Boolean]

# File lib/thinreports/core/shape/style/text.rb, line 49
def underline
  read_internal_style('font-style').include?('underline')
end
underline=(enable) click to toggle source

@param [Boolean] enable

# File lib/thinreports/core/shape/style/text.rb, line 54
def underline=(enable)
  write_font_style('underline', enable)
end
valign() click to toggle source

@return [:top, :middle, :bottom]

# File lib/thinreports/core/shape/style/text.rb, line 81
def valign
  vertical_align = read_internal_style('vertical-align')
  blank_value?(vertical_align) ? :top : vertical_align.to_sym
end
valign=(valign_name) click to toggle source

@param [:top, :center, :middle, :bottom] valign_name

# File lib/thinreports/core/shape/style/text.rb, line 87
def valign=(valign_name)
  if valign_name == :center
    warn '[DEPRECATION] :center value for valign style is deprecated' \
         ' and will be removed in thinreports-generator 1.0.' \
         ' Please use :middle instead of :center.'
    valign_name = :middle
  end

  verify_style_value(
    valign_name,
    %i[top middle bottom],
    'Only :top or :middle (:center), :bottom can be specified as valign.'
  )
  write_internal_style('vertical-align', valign_name.to_s)
end

Private Instance Methods

initialize_font_style() click to toggle source
# File lib/thinreports/core/shape/style/text.rb, line 105
def initialize_font_style
  styles['font-style'] ||= (@base_styles['font-style'] || []).dup
end
write_font_style(style_name, enable) click to toggle source
# File lib/thinreports/core/shape/style/text.rb, line 109
def write_font_style(style_name, enable)
  if enable
    styles['font-style'].push(style_name).uniq!
  else
    styles['font-style'].delete(style_name)
  end
end