Method: Spreadsheet::Format#initialize

Defined in:
lib/spreadsheet/format.rb

#initialize(opts = {}) {|_self| ... } ⇒ Format

Returns a new instance of Format.

Yields:

  • (_self)

Yield Parameters:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/spreadsheet/format.rb', line 90

def initialize opts = {}
  @font = Font.new client("Arial", "UTF-8"), family: :swiss
  @number_format = client "GENERAL", "UTF-8"
  @rotation = 0
  @pattern = 0
  @bottom_color = :black
  @top_color = :black
  @left_color = :black
  @right_color = :black
  @diagonal_color = :black
  @pattern_fg_color = :border
  @pattern_bg_color = :pattern_bg
  @regexes = {
    date: Regexp.new(client("[YMD]|d{2}|m{3}|y{2}", "UTF-8")),
    date_or_time: Regexp.new(client("[hmsYMD]", "UTF-8")),
    datetime: Regexp.new(client("([YMD].*[HS])|([HS].*[YMD])", "UTF-8")),
    time: Regexp.new(client("[hms]", "UTF-8")),
    number: Regexp.new(client("([#]|0+)", "UTF-8")),
    locale: Regexp.new(client(/\A\[\$-\S+\]/.to_s, "UTF-8"))
  }

  # Temp code to prevent merged formats in non-merged cells.
  @used_merge = 0
  update_format(opts)

  yield self if block_given?
end