Class: Spreadsheet::Font
- Inherits:
-
Object
- Object
- Spreadsheet::Font
- Defined in:
- lib/spreadsheet/font.rb
Overview
Font formatting data
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#bold=(bool) ⇒ Object
Sets #weight to :bold if(bool), :normal otherwise.
-
#color ⇒ Object
Font color.
-
#escapement ⇒ Object
Escapement Valid values: :normal, :superscript or :subscript.
-
#initialize(name, opts = {}) ⇒ Font
constructor
A new instance of Font.
-
#italic ⇒ Object
You can set the following boolean Font attributes * #italic * #strikeout * #outline * #shadow.
-
#key ⇒ Object
:nodoc:.
-
#weight ⇒ Object
Font weight Valid values: :normal, :bold or any positive Integer.
Methods included from Datatypes
Methods included from Compatibility
Constructor Details
#initialize(name, opts = {}) ⇒ Font
Returns a new instance of Font.
64 65 66 67 68 69 70 |
# File 'lib/spreadsheet/font.rb', line 64 def initialize name, opts={} self.name = name @color = :text opts.each do |key, val| self.send "#{key}=", val end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/spreadsheet/font.rb', line 11 def name @name end |
Instance Method Details
#bold=(bool) ⇒ Object
Sets #weight to :bold if(bool), :normal otherwise.
73 74 75 |
# File 'lib/spreadsheet/font.rb', line 73 def bold= bool self.weight = bool ? :bold : nil end |
#color ⇒ Object
Font color
21 |
# File 'lib/spreadsheet/font.rb', line 21 colors :color |
#escapement ⇒ Object
Escapement Valid values: :normal, :superscript or :subscript. Default: :normal
35 36 37 |
# File 'lib/spreadsheet/font.rb', line 35 enum :escapement, :normal, :superscript, :subscript, :subscript => :sub, :superscript => :super |
#italic ⇒ Object
You can set the following boolean Font attributes
-
#italic
-
#strikeout
-
#outline
-
#shadow
18 |
# File 'lib/spreadsheet/font.rb', line 18 boolean :italic, :strikeout, :outline, :shadow |
#key ⇒ Object
:nodoc:
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/spreadsheet/font.rb', line 76 def key # :nodoc: key = @name.dup underscore = client('_', 'UTF-8') key << underscore << client(size.to_s, 'US-ASCII') key << client('_', 'UTF-8') << client(weight.to_s, 'US-ASCII') key << client('_italic', 'UTF-8') if italic? key << client('_strikeout', 'UTF-8') if strikeout? key << client('_outline', 'UTF-8') if outline? key << client('_shadow', 'UTF-8') if shadow? key << underscore << client(escapement.to_s, 'US-ASCII') key << underscore << client(underline.to_s, 'US-ASCII') key << underscore << client(color.to_s, 'US-ASCII') key << underscore << client(family.to_s, 'US-ASCII') key << underscore << client(encoding.to_s, 'US-ASCII') end |
#weight ⇒ Object
Font weight Valid values: :normal, :bold or any positive Integer. In Excel:
100 <= weight <= 1000
:bold => 700
:normal => 400
Default: :normal
30 |
# File 'lib/spreadsheet/font.rb', line 30 enum :weight, :normal, :bold, Integer, :bold => :b |