Module: Cuker::ExcelSupport
- Included in:
- RubyXLModel
- Defined in:
- lib/cuker/helpers/formatters/ruby_x_l_model.rb
Constant Summary collapse
- EXCEL_BLANK =
''
- EXCEL_TABLE_PADDING =
7
Instance Method Summary collapse
- #excel_arg_hilight(str) ⇒ Object
- #excel_blank_pad(str) ⇒ Object
- #excel_bold(str) ⇒ Object
- #excel_bold_italics(str) ⇒ Object
- #excel_content_format(ary) ⇒ Object
- #excel_italics(str) ⇒ Object
- #excel_monospace(str) ⇒ Object
- #excel_title(keyword, title_ary) ⇒ Object
- #surround_color(str, color = nil) ⇒ Object
- #surround_panel(str, title = nil) ⇒ Object
-
#tableify(header_and_rows_ary, padding = 0) ⇒ Array
Properly spaced out tables def tableify header_ary, rows_ary www.rubydoc.info/gems/text-table/1.2.4.
Instance Method Details
#excel_arg_hilight(str) ⇒ Object
34 35 36 37 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 34 def excel_arg_hilight(str) # str.gsub(/<(.*)?>/, excel_bold_italics('<\1>')) str.gsub(/<.*?>/, &method(:excel_bold_italics)) end |
#excel_blank_pad(str) ⇒ Object
59 60 61 62 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 59 def excel_blank_pad str s = str.strip s.empty? ? EXCEL_BLANK : s end |
#excel_bold(str) ⇒ Object
44 45 46 47 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 44 def excel_bold str # make bold? str end |
#excel_bold_italics(str) ⇒ Object
39 40 41 42 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 39 def excel_bold_italics(str) # make excel_bold_italics? excel_bold(excel_italics(str)) end |
#excel_content_format(ary) ⇒ Object
25 26 27 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 25 def excel_content_format ary ary.join "\n" end |
#excel_italics(str) ⇒ Object
54 55 56 57 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 54 def excel_italics(str) # make excel_italics? str end |
#excel_monospace(str) ⇒ Object
49 50 51 52 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 49 def excel_monospace str # make monospaced? str end |
#excel_title(keyword, title_ary) ⇒ Object
29 30 31 32 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 29 def excel_title keyword, title_ary # "#{excel_bold "#{keyword}:"}\n #{title}\n " [excel_bold("#{keyword}:")] + title_ary end |
#surround_color(str, color = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 17 def surround_color str, color = nil if title "{color:#{color}} #{str} {color}" else "{color} #{str} {color}" end end |
#surround_panel(str, title = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 9 def surround_panel str, title = nil if title "{panel:title = #{title}} #{str} {panel}" else "{panel} #{str} {panel}" end end |
#tableify(header_and_rows_ary, padding = 0) ⇒ Array
Properly spaced out tables def tableify header_ary, rows_ary www.rubydoc.info/gems/text-table/1.2.4
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cuker/helpers/formatters/ruby_x_l_model.rb', line 68 def tableify header_and_rows_ary, padding = 0 table = Text::Table.new(:horizontal_padding => 1, :vertical_boundary => '-', :horizontal_boundary => '|', :boundary_intersection => '+', # :boundary_intersection => '-', # :boundary_intersection => ' ', :first_row_is_head => true, # :rows => header_and_rows_ary # works only for to_table ) table.head = header_and_rows_ary[0] table.rows = header_and_rows_ary[1..-1] # table.to_s # table.rows = header_and_rows_ary # # table = header_and_rows_ary.to_table(:first_row_is_head => true) res = table.to_s.split("\n") res.map {|row_str| ' ' * padding + row_str} end |