Module: Osheet::WorkbookApi

Included in:
Workbook
Defined in:
lib/osheet/workbook_api.rb

Defined Under Namespace

Classes: StyleBuild, TemplatedElement

Instance Method Summary collapse

Instance Method Details

#border(*args) ⇒ Object



150
151
152
# File 'lib/osheet/workbook_api.rb', line 150

def border(*args)
  element_stack.current.border(*args)
end

#cell(*args, &block) ⇒ Object

used on: row



134
135
136
137
138
139
140
# File 'lib/osheet/workbook_api.rb', line 134

def cell(*args, &block)
  if args.empty? && block.nil?
    cells.last
  else
    TemplatedElement.new(self, :cell, *args, &block).add
  end
end

#cellsObject



27
28
29
# File 'lib/osheet/workbook_api.rb', line 27

def cells
  rows.last.cells
end

#column(*args, &block) ⇒ Object

used on: worksheet



120
121
122
# File 'lib/osheet/workbook_api.rb', line 120

def column(*args, &block)
  TemplatedElement.new(self, :column, *args, &block).add
end

#columnsObject



19
20
21
# File 'lib/osheet/workbook_api.rb', line 19

def columns
  worksheets.last.columns
end

#format(*args) ⇒ Object

used by: cell



175
176
177
178
179
180
181
# File 'lib/osheet/workbook_api.rb', line 175

def format(*args)
  current_format = element_stack.current.format(*args)   # for self referencing
  if !args.empty? && self.writer                         # for writing
    self.writer.style(element_stack.current.style_class, current_format)
  end
  current_format
end

#meta(*args) ⇒ Object

element attribute API



156
157
158
# File 'lib/osheet/workbook_api.rb', line 156

def meta(*args)
  element_stack.current.meta(*args)
end

#partial(*args, &build) ⇒ Object



39
40
41
42
43
# File 'lib/osheet/workbook_api.rb', line 39

def partial(*args, &build)
  Osheet::Partial.new(*args, &build).tap do |partial|
    element_stack.current.partial(partial)
  end
end

#row(*args, &block) ⇒ Object

used on: worksheet



125
126
127
128
129
130
131
# File 'lib/osheet/workbook_api.rb', line 125

def row(*args, &block)
  if args.empty? && block.nil?
    rows.last
  else
    TemplatedElement.new(self, :row, *args, &block).add
  end
end

#rowsObject



23
24
25
# File 'lib/osheet/workbook_api.rb', line 23

def rows
  worksheets.last.rows
end

#style(*args, &build) ⇒ Object



60
61
62
63
64
# File 'lib/osheet/workbook_api.rb', line 60

def style(*args, &build)
  StyleBuild.new(self, *args, &build).add do |build|
    build.call
  end
end

#style_class(value = nil) ⇒ Object

used by: column, row, cell



166
167
168
169
170
171
172
# File 'lib/osheet/workbook_api.rb', line 166

def style_class(value=nil)
  current_class  = element_stack.current.style_class(value)  # for self referencing
  if value && self.writer                                    # for writing
    self.writer.style(current_class, element_stack.current.format)
  end
  current_class
end

#template(*args, &build) ⇒ Object

markup handling API



33
34
35
36
37
# File 'lib/osheet/workbook_api.rb', line 33

def template(*args, &build)
  Osheet::Template.new(*args, &build).tap do |template|
    element_stack.current.template(template)
  end
end

#title(*args) ⇒ Object

used by: workbook_element



184
185
186
# File 'lib/osheet/workbook_api.rb', line 184

def title(*args)
  element_stack.current.title(*args)
end

#worksheet(*args, &block) ⇒ Object

used on: workbook



111
112
113
114
115
116
117
# File 'lib/osheet/workbook_api.rb', line 111

def worksheet(*args, &block)
  if args.empty? && block.nil?
    worksheets.last
  else
    TemplatedElement.new(self, :worksheet, *args, &block).add
  end
end

#worksheetsObject



15
16
17
# File 'lib/osheet/workbook_api.rb', line 15

def worksheets
  workbook.worksheets
end