Class SimpleCellStyle
In: lib/simple_cell_style.rb
Parent: Object

PDF 文書のスタイルのモデル。

Methods

new  

Included Modules

DocumentStyles::StyleMargin DocumentStyles::StyleAlignment DocumentStyles::StyleBorderWidth

Attributes

color  [RW] 
font_size  [RW] 
line_height  [RW] 

Public Class methods

[Source]

    # File lib/simple_cell_style.rb, line 7
 7:   def initialize(options={})
 8:     # default value
 9:     @color = {
10:       :border => DocumentStyles::Color.new(0, 0, 0),
11:       :text => DocumentStyles::Color.new(0, 0, 0),
12:       :fill => nil # can be nil (transparent)
13:     }
14:     @font_size = 12.0 # pt
15:     @line_height = 5.0 # mm
16: 
17:     # retrieve options
18:     options.each do |key,val|
19:       case(key)
20:       when :border_color
21:         if val.kind_of?(Array)
22:           @color[:border] = DocumentStyles::Color.new(val[0], val[1], val[2])
23:         elsif val.kind_of?(DocumentStyles::Color)
24:           @color[:border] = val
25:         else
26:           raise "Invalid color expression."
27:         end
28:       when :text_color
29:         if val.kind_of?(Array)
30:           @color[:text] = DocumentStyles::Color.new(val[0], val[1], val[2])
31:         elsif val.kind_of?(DocumentStyles::Color)
32:           @color[:text] = val
33:         else
34:           raise "Invalid color expression."
35:         end
36:       when :fill_color
37:         if val.kind_of?(Array)
38:           @color[:fill] = DocumentStyles::Color.new(val[0], val[1], val[2])
39:         elsif val.kind_of?(DocumentStyles::Color) || val == nil
40:           @color[:fill] = val
41:         else
42:           raise "Invalid color expression."
43:         end
44:       when :top_margin
45:         self.margin[:top] = val
46:       when :bottom_margin
47:         self.margin[:bottom] = val
48:       when :left_margin
49:         self.margin[:left] = val
50:       when :right_margin
51:         self.margin[:right] = val
52:       when :top_border_width
53:         self.border_width[:top] = val
54:       when :bottom_border_width
55:         self.border_width[:bottom] = val
56:       when :left_border_width
57:         self.border_width[:left] = val
58:       when :right_border_width
59:         self.border_width[:right] = val
60:       when :align
61:         self.align = val
62:       when :font_size
63:         @font_size = val
64:       when :line_height
65:         @line_height = val
66:       end
67:     end
68:   end

[Validate]