Class: Axlsx::Builder::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/builder.rb

Direct Known Subclasses

Title

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Element

Returns a new instance of Element.



65
66
67
68
69
# File 'lib/axlsx/builder.rb', line 65

def initialize(attrs={})
  @pos = Position.new
  @format = Format.new
  super
end

Instance Attribute Details

#border_thicknessObject

Returns the value of attribute border_thickness.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def border_thickness
  @border_thickness
end

#bordersObject

Returns the value of attribute borders.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def borders
  @borders
end

#commentObject

Returns the value of attribute comment.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def comment
  @comment
end

#formatObject

Returns the value of attribute format.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def format
  @format
end

#mergeObject

Returns the value of attribute merge.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def merge
  @merge
end

#posObject

Returns the value of attribute pos.



61
62
63
# File 'lib/axlsx/builder.rb', line 61

def pos
  @pos
end

#textObject

Returns the value of attribute text.



62
63
64
# File 'lib/axlsx/builder.rb', line 62

def text
  @text
end

Instance Method Details

#colObject



76
# File 'lib/axlsx/builder.rb', line 76

def col; pos.col; end

#colorObject



79
# File 'lib/axlsx/builder.rb', line 79

def color; format.color; end

#combined_styleObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/axlsx/builder.rb', line 83

def combined_style
  combined_style = {}
  if self.style
    combined_style.merge!(b: true) if self.style.include? :bold
    combined_style.merge!(i: true) if self.style.include? :italic
    combined_style.merge!(u: true) if self.style.include? :underline
    combined_style.merge!(alignment: {horizontal: :center}) if self.style.include? :center
    combined_style.merge!(sz: 12) if self.style.include? :lg_font
  end
  combined_style.merge!(sz: self.font.size)
  combined_style.merge!(font_name: self.font.name)
  combined_style.merge!(bg_color: self.color) if self.color
  combined_style.merge!(fg_color: self.font.color)
  combined_style.merge!(alignment: {horizontal: h_align, vertical: v_align})
  if self.borders == true
    combined_style.merge! border: {style: self.border_thickness || :medium, color: '00000000'}
  elsif self.borders
    combined_style.merge! border: {style: self.border_thickness || :medium, color: '00000000', edges: self.borders}
  end
  combined_style
end

#fontObject



78
# File 'lib/axlsx/builder.rb', line 78

def font; format.font; end

#h_alignObject



80
# File 'lib/axlsx/builder.rb', line 80

def h_align; format.alignment.horizontal; end

#rowObject



75
# File 'lib/axlsx/builder.rb', line 75

def row; pos.row; end

#styleObject



77
# File 'lib/axlsx/builder.rb', line 77

def style; format.style; end

#v_alignObject



81
# File 'lib/axlsx/builder.rb', line 81

def v_align; format.alignment.vertical; end