Class: RGhost::Show

Inherits:
PsObject show all
Includes:
RubyToPs
Defined in:
lib/rghost/show.rb

Overview

Writes a text on the current row or point with align.

Constant Summary collapse

DEFAULT_OPTIONS =
{:tag => :default_font, :align => :show_left}

Constants included from RubyToPs

RubyToPs::UTF8_ENCODINGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RubyToPs

#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(text, options = { :align=>:show_left, :tag => :default_font, :color => 0 }) ⇒ Show

Returns a new instance of Show.



69
70
71
72
# File 'lib/rghost/show.rb', line 69

def initialize(text,options={ :align=>:show_left, :tag => :default_font, :color => 0 } )
  @text = text
  @options=DEFAULT_OPTIONS.dup.merge(options)
end

Instance Attribute Details

#alignObject

Returns the value of attribute align.



7
8
9
# File 'lib/rghost/show.rb', line 7

def align
  @align
end

#tagObject

Returns the value of attribute tag.



7
8
9
# File 'lib/rghost/show.rb', line 7

def tag
  @tag
end

#textObject

Returns the value of attribute text.



7
8
9
# File 'lib/rghost/show.rb', line 7

def text
  @text
end

Instance Method Details

#psObject



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/rghost/show.rb', line 74

def ps
  rtext=RGhost::PsObject.new
  #rtext.raw Color.create(@options[:color] || 0) 
  if @options[:with] || @options[:tag]
    f="_#{@options[:with] || @options[:tag]}"
    rtext.raw f 
  end
  rtext.raw RGhost::Color.create(@options[:color])  if @options[:color]
  rtext.raw to_string(@text)
  rtext.raw @options[:align]
  
  rtext.graphic_scope
end