Module: TankaRenderer::Renderer::Base

Included in:
Image, PDF
Defined in:
lib/tanka_renderer/renderer/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#body_colorObject

Returns the value of attribute body_color.



9
10
11
# File 'lib/tanka_renderer/renderer/base.rb', line 9

def body_color
  @body_color
end

#fontObject

Returns the value of attribute font.



8
9
10
# File 'lib/tanka_renderer/renderer/base.rb', line 8

def font
  @font
end

#heightObject

Returns the value of attribute height.



8
9
10
# File 'lib/tanka_renderer/renderer/base.rb', line 8

def height
  @height
end

#text_colorObject

Returns the value of attribute text_color.



9
10
11
# File 'lib/tanka_renderer/renderer/base.rb', line 9

def text_color
  @text_color
end

#verticalObject

Returns the value of attribute vertical.



10
11
12
# File 'lib/tanka_renderer/renderer/base.rb', line 10

def vertical
  @vertical
end

#widthObject

Returns the value of attribute width.



8
9
10
# File 'lib/tanka_renderer/renderer/base.rb', line 8

def width
  @width
end

Instance Method Details

#draw(context, text) ⇒ Object



28
29
30
31
# File 'lib/tanka_renderer/renderer/base.rb', line 28

def draw(context, text)
  draw_body(context)
  draw_text(context, text)
end

#guess_font(part_of_font_name) ⇒ Object



20
21
22
# File 'lib/tanka_renderer/renderer/base.rb', line 20

def guess_font(part_of_font_name)
  @font = Fontdock::Local.find(part_of_font_name)
end

#initializeObject



11
12
13
14
15
16
17
18
# File 'lib/tanka_renderer/renderer/base.rb', line 11

def initialize
  @width = 300
  @height = 500
  @font = "IPAMincho"
  @body_color = :white
  @text_color = :black
  @vertical = true
end

#render(text, output_path) ⇒ Object



24
25
26
# File 'lib/tanka_renderer/renderer/base.rb', line 24

def render(text, output_path)
  @width, @height = @height, @width unless @vertical
end