Class: Column

Inherits:
Object
  • Object
show all
Defined in:
lib/surpass/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, parent) ⇒ Column

Returns a new instance of Column.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/surpass/column.rb', line 8

def initialize(index, parent)
  is_int = index.is_a?(Integer)
  in_range = (index >= 0) && (index <= 255)
  raise "column index #{index} is not valid" unless is_int && in_range
  
  @index = index
  @parent = parent
  @parent_wb = parent.parent
  @xf_index = 0x0F
  
  @width = 0x0B92
  @hidden = 0
  @level = 0
  @collapse = 0
end

Instance Attribute Details

#collapseObject

Returns the value of attribute collapse.



6
7
8
# File 'lib/surpass/column.rb', line 6

def collapse
  @collapse
end

#hiddenObject

Returns the value of attribute hidden.



4
5
6
# File 'lib/surpass/column.rb', line 4

def hidden
  @hidden
end

#indexObject

Returns the value of attribute index.



2
3
4
# File 'lib/surpass/column.rb', line 2

def index
  @index
end

#levelObject

Returns the value of attribute level.



5
6
7
# File 'lib/surpass/column.rb', line 5

def level
  @level
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/surpass/column.rb', line 3

def width
  @width
end

Instance Method Details

#set_style(style) ⇒ Object



32
33
34
# File 'lib/surpass/column.rb', line 32

def set_style(style)
  @xf_index = @parent_wb.add_style(style)
end

#to_biffObject



24
25
26
27
28
29
30
# File 'lib/surpass/column.rb', line 24

def to_biff
  options =  (as_numeric(@hidden) & 0x01) << 0
  options |= (@level & 0x07) << 8
  options |= (as_numeric(@collapse) & 0x01) << 12
  
  ColInfoRecord.new(@index, @index, @width, @xf_index, options).to_biff
end

#width_in_pixelsObject



36
37
38
39
# File 'lib/surpass/column.rb', line 36

def width_in_pixels
    # *** Approximation ****
  (self.width * 0.0272 + 0.446).round
end