Class: Clarus::TextBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/clarus/text_block.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, text_style) ⇒ TextBlock

Returns a new instance of TextBlock.



3
4
5
6
7
8
9
10
11
12
# File 'lib/clarus/text_block.rb', line 3

def initialize(text, text_style)
  @text = text
  if text_style == :bold
    @style = '<w:b/>\n'
  elsif text_style == :underline
    @style = '<w:u w:val="single"/>\n'
  elsif text_style == :italic
    @style = '<w:i/>\n'
  end
end

Instance Method Details

#renderObject



14
15
16
17
18
# File 'lib/clarus/text_block.rb', line 14

def render
  document_template = File.read(File.expand_path('../templates/text_block_template.erb', __FILE__))
  Erubis::Eruby.new(document_template).result(:style => @style,
                                              :text => @text)
end