Class: Osheet::Workbook
- Inherits:
-
Object
- Object
- Osheet::Workbook
- Includes:
- Associations, Instance, MarkupElement
- Defined in:
- lib/osheet/workbook.rb
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(&block) ⇒ Workbook
constructor
A new instance of Workbook.
- #partial(name, &block) ⇒ Object
- #partials ⇒ Object
- #style(*selectors, &block) ⇒ Object
- #styles ⇒ Object
- #template(element, name, &block) ⇒ Object
- #templates ⇒ Object
- #title(value = nil) ⇒ Object
- #use(mixin) ⇒ Object
- #writer ⇒ Object
Methods included from MarkupElement
Methods included from Associations
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
#attributes ⇒ Object
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 |
#partials ⇒ Object
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 |
#styles ⇒ Object
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 |
#templates ⇒ Object
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 |
#writer ⇒ Object
56 57 58 |
# File 'lib/osheet/workbook.rb', line 56 def writer XmlssWriter::Base.new(:workbook => self) end |