Class: Rbxl::WriteOnlyCell

Inherits:
Object
  • Object
show all
Defined in:
lib/rbxl/write_only_cell.rb

Overview

Wraps a write-side cell value so that a style id can be associated with it without widening every call site to a Hash or Array.

Instances are passed transparently to Rbxl::WriteOnlyWorksheet#append (or <<) in place of a plain value:

cell = Rbxl::WriteOnlyCell.new(42, style_id: 1)
sheet << ["id", cell]

The value is serialized using the same type rules as a bare value; the style_id, when present, is emitted as the cell’s s attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, style_id: nil) ⇒ WriteOnlyCell

Returns a new instance of WriteOnlyCell.

Parameters:

  • value (Object)

    Ruby value to serialize into the cell

  • style_id (Integer, nil) (defaults to: nil)

    optional style index



23
24
25
26
# File 'lib/rbxl/write_only_cell.rb', line 23

def initialize(value, style_id: nil)
  @value = value
  @style_id = style_id
end

Instance Attribute Details

#style_idInteger? (readonly)

Returns style index into the workbook’s cellXfs table.

Returns:

  • (Integer, nil)

    style index into the workbook’s cellXfs table



19
20
21
# File 'lib/rbxl/write_only_cell.rb', line 19

def style_id
  @style_id
end

#valueObject (readonly)

Returns underlying Ruby value (String, Numeric, Boolean, Date/DateTime/Time, or nil).

Returns:

  • (Object)

    underlying Ruby value (String, Numeric, Boolean, Date/DateTime/Time, or nil)



16
17
18
# File 'lib/rbxl/write_only_cell.rb', line 16

def value
  @value
end