Class: RubyXL::Font

Inherits:
OOXMLObject show all
Defined in:
lib/rubyXL/objects/font.rb

Overview

Constant Summary collapse

MAX_DIGIT_WIDTH =

Since we have no capability to load the actual fonts, we’ll have to live with the default.

7

Instance Method Summary collapse

Methods included from OOXMLObjectClassMethods

#define_attribute, #define_child_node, #define_element_name, #obtain_class_variable, #parse, #set_countable

Methods included from OOXMLObjectInstanceMethods

#before_write_xml, #dup, #index_in_collection, #initialize, #write_xml

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rubyXL/objects/font.rb', line 30

def ==(other)
 (!(self.i && self.i.val) == !(other.i && other.i.val)) &&
   (!(self.b && self.b.val) == !(other.b && other.b.val)) &&
   (!(self.u && self.u.val) == !(other.u && other.u.val)) &&
   (!(self.strike && self.strike.val) == !(other.strike && other.strike.val)) &&
   ((self.name && self.name.val) == (other.name && other.name.val)) &&
   ((self.sz && self.sz.val) == (other.sz && other.sz.val)) &&
   (self.color == other.color) # Need to write proper comparison for color
end

#get_nameObject



72
73
74
# File 'lib/rubyXL/objects/font.rb', line 72

def get_name
  name && name.val
end

#get_rgb_colorObject



88
89
90
# File 'lib/rubyXL/objects/font.rb', line 88

def get_rgb_color
  color && color.rgb
end

#get_sizeObject



80
81
82
# File 'lib/rubyXL/objects/font.rb', line 80

def get_size
  sz && sz.val
end

#is_boldObject



48
49
50
# File 'lib/rubyXL/objects/font.rb', line 48

def is_bold
  b && b.val
end

#is_italicObject



40
41
42
# File 'lib/rubyXL/objects/font.rb', line 40

def is_italic
  i && i.val
end

#is_strikethroughObject



64
65
66
# File 'lib/rubyXL/objects/font.rb', line 64

def is_strikethrough
  strike && strike.val
end

#is_underlinedObject



56
57
58
# File 'lib/rubyXL/objects/font.rb', line 56

def is_underlined
  u && u.val
end

#set_bold(val) ⇒ Object



52
53
54
# File 'lib/rubyXL/objects/font.rb', line 52

def set_bold(val)
  self.b = RubyXL::BooleanValue.new(:val => val)
end

#set_italic(val) ⇒ Object



44
45
46
# File 'lib/rubyXL/objects/font.rb', line 44

def set_italic(val)
  self.i = RubyXL::BooleanValue.new(:val => val)
end

#set_name(val) ⇒ Object



76
77
78
# File 'lib/rubyXL/objects/font.rb', line 76

def set_name(val)
  self.name = RubyXL::StringValue.new(:val => val)
end

#set_rgb_color(font_color) ⇒ Object

Helper method to modify the font color



93
94
95
# File 'lib/rubyXL/objects/font.rb', line 93

def set_rgb_color(font_color)
  self.color = RubyXL::Color.new(:rgb => font_color.to_s)
end

#set_size(val) ⇒ Object



84
85
86
# File 'lib/rubyXL/objects/font.rb', line 84

def set_size(val)
  self.sz = RubyXL::FloatValue.new(:val => val)
end

#set_strikethrough(val) ⇒ Object



68
69
70
# File 'lib/rubyXL/objects/font.rb', line 68

def set_strikethrough(val)
  self.strike = RubyXL::BooleanValue.new(:val => val)
end

#set_underline(val) ⇒ Object



60
61
62
# File 'lib/rubyXL/objects/font.rb', line 60

def set_underline(val)
  self.u = RubyXL::BooleanValue.new(:val => val)
end