File: horizontal_line.rb

package info (click to toggle)
ruby-rghost 0.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,188 kB
  • sloc: ruby: 3,374; makefile: 6; sh: 1
file content (39 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "rghost/ps_object"
require "rghost/units"
# Creates horizontal line on the current row.
class RGhost::HorizontalLine < RGhost::PsObject
  DEFAULT_OPTIONS = {start_in: :limit_left, size: :area_x,
                     border: RGhost::Border::DEFAULT_OPTIONS}

  # Examples
  #
  # Drawing line on middle
  #
  # doc.show "Foo Bar"
  # doc.horizontal_line :middle
  #
  # link:images/horizontal_line01.png
  #
  # Drawing line on bottom and customizing border attributes
  #
  # doc.show "Foo Bar"
  # doc.horizontal_line :bottom, :border => {:dash => [1,2,2,2], :color => :red}
  #
  # link:images/horizontal_line02.png
  #
  # Specifies size and where will start of line
  #
  # doc.show "Foo Bar"
  # doc.horizontal_line :top, :start_in => 2, :size => 5, :border => {:dash => [1,2,2,2], :color => :red}
  #
  # link:images/horizontal_line03.png

  def initialize(valign = :middle, options = {})
    @options = DEFAULT_OPTIONS.dup.merge(options)
    start_in = RGhost::Units.parse(@options[:start_in])
    size = RGhost::Units.parse(@options[:size])
    border = RGhost::Border.new(@options[:border])
    super("gsave #{border.ps}  #{start_in} #{size} horizontal_line_#{valign} grestore")
    # super("#{start_in} #{size} horizontal_line_#{valign}")
  end
end