Class: Thinreports::BasicReport::Core::Shape::Style::Text

Inherits:
Basic
  • Object
show all
Defined in:
lib/thinreports/basic_report/core/shape/style/text.rb

Instance Attribute Summary

Attributes inherited from Basic

#visible

Attributes inherited from Base

#accessible_styles, #styles

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, accessible_styles, #copy, #finalized_styles, #has_style?, #identifier, inherited, #read_internal_style, style_accessible, style_accessor, style_reader, style_writer, #write_internal_style

Methods included from Utils

#blank_value?, #call_block_in, #deep_copy, included

Constructor Details

#initializeText

Returns a new instance of Text.



24
25
26
27
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 24

def initialize(*)
  super
  initialize_font_style
end

Instance Method Details

#align:left, ...

Returns:

  • (:left, :center, :right)


70
71
72
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 70

def align
  read_internal_style('text-align').to_sym
end

#align=(align_name) ⇒ Object

Parameters:

  • align_name (:left, :center, :right)


75
76
77
78
79
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 75

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

#boldBoolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 30

def bold
  read_internal_style('font-style').include?('bold')
end

#bold=(enable) ⇒ Object

Parameters:

  • enable (Boolean)


35
36
37
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 35

def bold=(enable)
  write_font_style('bold', enable)
end

#colorString

Returns:

  • (String)


16
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 16

style_accessor :color, 'color'

#color=(v) ⇒ Object

Parameters:

  • v (String)


16
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 16

style_accessor :color, 'color'

#font_sizeNumeric, String

Returns:

  • (Numeric, String)


22
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 22

style_accessor :font_size, 'font-size'

#font_size=(v) ⇒ Object

Parameters:

  • v (Numeric, String)


22
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 22

style_accessor :font_size, 'font-size'

#italicBoolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 40

def italic
  read_internal_style('font-style').include?('italic')
end

#italic=(enable) ⇒ Object

Parameters:

  • enable (Boolean)


45
46
47
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 45

def italic=(enable)
  write_font_style('italic', enable)
end

#linethroughBoolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 60

def linethrough
  read_internal_style('font-style').include?('linethrough')
end

#linethrough=(enable) ⇒ Object

Parameters:

  • enable (Boolean)


65
66
67
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 65

def linethrough=(enable)
  write_font_style('linethrough', enable)
end

#underlineBoolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 50

def underline
  read_internal_style('font-style').include?('underline')
end

#underline=(enable) ⇒ Object

Parameters:

  • enable (Boolean)


55
56
57
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 55

def underline=(enable)
  write_font_style('underline', enable)
end

#valign:top, ...

Returns:

  • (:top, :middle, :bottom)


82
83
84
85
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 82

def valign
  vertical_align = read_internal_style('vertical-align')
  blank_value?(vertical_align) ? :top : vertical_align.to_sym
end

#valign=(valign_name) ⇒ Object

Parameters:

  • valign_name (:top, :center, :middle, :bottom)


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/thinreports/basic_report/core/shape/style/text.rb', line 88

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