Class: Osheet::Workbook

Inherits:
Object
  • Object
show all
Includes:
Associations, Instance, MarkupElement
Defined in:
lib/osheet/workbook.rb

Instance Method Summary collapse

Methods included from MarkupElement

#add

Methods included from Associations

included

Constructor Details

#initialize(&block) ⇒ Workbook

Returns a new instance of Workbook.



18
19
20
21
22
23
24
25
26
27
# File 'lib/osheet/workbook.rb', line 18

def initialize(&block)
  set_ivar(:title, nil)
  set_ivar(:styles, StyleSet.new)
  set_ivar(:templates, TemplateSet.new)
  set_ivar(:partials, PartialSet.new)
  if block_given?
    set_binding_ivars(block.binding)
    instance_eval(&block)
  end
end

Instance Method Details

#attributesObject



46
47
48
# File 'lib/osheet/workbook.rb', line 46

def attributes
  { :title => get_ivar(:title) }
end

#partial(name, &block) ⇒ Object



41
# File 'lib/osheet/workbook.rb', line 41

def partial(name, &block); push_ivar(:partials, Partial.new(name, &block)); end

#partialsObject



42
43
44
# File 'lib/osheet/workbook.rb', line 42

def partials
  get_ivar(:partials)
end

#style(*selectors, &block) ⇒ Object



33
# File 'lib/osheet/workbook.rb', line 33

def style(*selectors, &block); push_ivar(:styles, Style.new(*selectors, &block)); end

#stylesObject



34
35
36
# File 'lib/osheet/workbook.rb', line 34

def styles
  get_ivar(:styles)
end

#template(element, name, &block) ⇒ Object



37
# File 'lib/osheet/workbook.rb', line 37

def template(element, name, &block); push_ivar(:templates, Template.new(element, name, &block)); end

#templatesObject



38
39
40
# File 'lib/osheet/workbook.rb', line 38

def templates
  get_ivar(:templates)
end

#title(value = nil) ⇒ Object



29
30
31
# File 'lib/osheet/workbook.rb', line 29

def title(value=nil)
  !value.nil? ? set_ivar(:title, value) : get_ivar(:title)
end

#use(mixin) ⇒ Object



50
51
52
53
54
# File 'lib/osheet/workbook.rb', line 50

def use(mixin)
  (mixin.styles || []).each{ |s| push_ivar(:styles, s) }
  (mixin.templates || []).each{ |t| push_ivar(:templates, t) }
  (mixin.partials || []).each{ |p| push_ivar(:partials, p) }
end

#writerObject



56
57
58
# File 'lib/osheet/workbook.rb', line 56

def writer
  XmlssWriter::Base.new(:workbook => self)
end