Class: Xmlss::Workbook
- Inherits:
-
Object
- Object
- Xmlss::Workbook
- Defined in:
- lib/xmlss/workbook.rb
Instance Method Summary collapse
- #alignment(*args, &block) ⇒ Object
- #border(*args, &block) ⇒ Object
- #borders(*args, &block) ⇒ Object
- #cell(*args, &block) ⇒ Object
- #column(*args, &block) ⇒ Object
- #data(*args, &block) ⇒ Object
- #font(*args, &block) ⇒ Object
-
#initialize(opts = {}, &build) ⇒ Workbook
constructor
A new instance of Workbook.
- #interior(*args, &block) ⇒ Object
- #number_format(*args, &block) ⇒ Object
- #protection(*args, &block) ⇒ Object
- #row(*args, &block) ⇒ Object
-
#style(*args, &block) ⇒ Object
Workbook styles API.
- #to_file(path) ⇒ Object
- #to_s ⇒ Object
-
#worksheet(*args, &block) ⇒ Object
Workbook elements API.
Constructor Details
#initialize(opts = {}, &build) ⇒ Workbook
Returns a new instance of Workbook.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/xmlss/workbook.rb', line 8 def initialize(opts={}, &build) # (don't pollute workbook scope that the build may run in) # apply :data options to workbook scope data = (opts || {})[:data] || {} if (data.keys.map(&:to_s) & self.public_methods.map(&:to_s)).size > 0 raise ArgumentError, "data conflicts with template public methods." end = class << self; self; end data.each {|key, value| .class_eval { define_method(key){value} }} # setup the Undies xml writer with any :output options @__xmlss_undies_writer = UndiesWriter.new((opts || {})[:output] || {}) # run any instance workbook build given instance_eval(&build) if build end |
Instance Method Details
#alignment(*args, &block) ⇒ Object
76 77 78 79 80 |
# File 'lib/xmlss/workbook.rb', line 76 def alignment(*args, &block) Style::Alignment.new(*args).tap do |style| @__xmlss_undies_writer.alignment(style, &block) end end |
#border(*args, &block) ⇒ Object
86 87 88 89 90 |
# File 'lib/xmlss/workbook.rb', line 86 def border(*args, &block) Style::Border.new(*args).tap do |style| @__xmlss_undies_writer.border(style, &block) end end |
#borders(*args, &block) ⇒ Object
82 83 84 |
# File 'lib/xmlss/workbook.rb', line 82 def borders(*args, &block) @__xmlss_undies_writer.borders(&block) end |
#cell(*args, &block) ⇒ Object
56 57 58 59 60 |
# File 'lib/xmlss/workbook.rb', line 56 def cell(*args, &block) Element::Cell.new(*args).tap do |elem| @__xmlss_undies_writer.cell(elem, &block) end end |
#column(*args, &block) ⇒ Object
44 45 46 47 48 |
# File 'lib/xmlss/workbook.rb', line 44 def column(*args, &block) Element::Column.new(*args).tap do |elem| @__xmlss_undies_writer.column(elem, &block) end end |
#data(*args, &block) ⇒ Object
62 63 64 65 66 |
# File 'lib/xmlss/workbook.rb', line 62 def data(*args, &block) Element::Data.new(*args).tap do |elem| @__xmlss_undies_writer.data(elem, &block) end end |
#font(*args, &block) ⇒ Object
92 93 94 95 96 |
# File 'lib/xmlss/workbook.rb', line 92 def font(*args, &block) Style::Font.new(*args).tap do |style| @__xmlss_undies_writer.font(style, &block) end end |
#interior(*args, &block) ⇒ Object
98 99 100 101 102 |
# File 'lib/xmlss/workbook.rb', line 98 def interior(*args, &block) Style::Interior.new(*args).tap do |style| @__xmlss_undies_writer.interior(style, &block) end end |
#number_format(*args, &block) ⇒ Object
104 105 106 107 108 |
# File 'lib/xmlss/workbook.rb', line 104 def number_format(*args, &block) Style::NumberFormat.new(*args).tap do |style| @__xmlss_undies_writer.number_format(style, &block) end end |
#protection(*args, &block) ⇒ Object
110 111 112 113 114 |
# File 'lib/xmlss/workbook.rb', line 110 def protection(*args, &block) Style::Protection.new(*args).tap do |style| @__xmlss_undies_writer.protection(style, &block) end end |
#row(*args, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/xmlss/workbook.rb', line 50 def row(*args, &block) Element::Row.new(*args).tap do |elem| @__xmlss_undies_writer.row(elem, &block) end end |
#style(*args, &block) ⇒ Object
Workbook styles API
70 71 72 73 74 |
# File 'lib/xmlss/workbook.rb', line 70 def style(*args, &block) Style::Base.new(*args).tap do |style| @__xmlss_undies_writer.style(style, &block) end end |
#to_file(path) ⇒ Object
30 31 32 33 34 |
# File 'lib/xmlss/workbook.rb', line 30 def to_file(path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w') { |f| f.write self.to_s } File.exists?(path) ? path : false end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/xmlss/workbook.rb', line 26 def to_s @__xmlss_undies_writer.workbook end |
#worksheet(*args, &block) ⇒ Object
Workbook elements API
38 39 40 41 42 |
# File 'lib/xmlss/workbook.rb', line 38 def worksheet(*args, &block) Element::Worksheet.new(*args).tap do |elem| @__xmlss_undies_writer.worksheet(elem, &block) end end |