Class: RGhost::Barcode::Base
- Inherits:
-
Parameter
- Object
- Parameter
- RGhost::Barcode::Base
- Defined in:
- lib/rghost_barcode/rghost_barcode_base.rb
Overview
Base of all kinds of barcodes. It’s used to creates barcode. For more details about options see groups.google.com/group/postscriptbarcode/web/Options
Options
Facades
-
:text
RGhost::Barcode::Text -
:guard
RGhost::Barcode::Guard -
:border
RGhost::Barcode::Border
Options. Between parenthesis the original parameter.
-
:scale
Scale in Array(). Example for twice the original size, :scale => [2,2] -
:rotate
Rotate angle. -
:color
(barcolor) Foreground color. -
:background
(backgroundcolor) -
:x and :y
Position. RGhost::Config::GS will be used. Default :current_row and :limit_left -
:width and :height
(width and height). Width and height of barcode, RGhost::Config::GS will be used.
Example: doc=Document.new doc.barcode_interleaved2of5(‘0123456789’,
:text => {:size => 10, :offset => [0,-10], :enable => [:text, :check, :checkintext] },
:border => {:width => 4, :left => 15, :right => 15, :show => true},
:height => 2
)
Without options doc=Document.new doc.barcode_code39(‘0123456789’)
Direct Known Subclasses
Auspost, Azteccode, Code11, Code128, Code2of5, Code39, Code93, Datamatrix, Ean13, Ean2, Ean5, Ean8, Interleaved2of5, Isbn, Kix, Maxicode, Msi, Onecode, Pdf417, Pharmacode, Plessey, Postnet, Qrcode, Rationalizedcodabar, Raw, Royalmail, Rss14, Rssexpanded, Rsslimited, Symbol, Upca, Upce
Instance Attribute Summary collapse
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#guard ⇒ Object
readonly
Returns the value of attribute guard.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(barcode_string, options = {}) ⇒ Base
constructor
A new instance of Base.
- #make ⇒ Object
- #ps ⇒ Object
Constructor Details
#initialize(barcode_string, options = {}) ⇒ Base
Returns a new instance of Base.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 165 def initialize(,={}) ||={} @options=.dup @options[:x]||= :limit_left @options[:y]||= :current_row @barcode= @text = RGhost::Barcode::Text.new(@options[:text]) @guard = RGhost::Barcode::Guard.new(@options[:guard]) @border = RGhost::Barcode::Border.new(@options[:border]) @point=RGhost::Cursor.translate(@options) @rotate=RGhost::Cursor.rotate @options[:rotate] @scale=RGhost::Scale.new @options[:scale][0],@options[:scale][1] if @options[:scale] [:scale, :enable, :text,:guard,:border, :x, :y, :rotate].each{|v| @options.delete v} super(@options) @self_name=self.class.to_s.downcase.split(/::/).last # RGhost::Config::GS[:preload] << @self_name end |
Instance Attribute Details
#border ⇒ Object (readonly)
Returns the value of attribute border.
163 164 165 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 163 def border @border end |
#guard ⇒ Object (readonly)
Returns the value of attribute guard.
163 164 165 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 163 def guard @guard end |
#point ⇒ Object (readonly)
Returns the value of attribute point.
163 164 165 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 163 def point @point end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
163 164 165 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 163 def text @text end |
Instance Method Details
#make ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 185 def make [:x,:y].each{|v| @options.delete v} @options.each do |key,value| case key when :color then add_color("barcolor", value) when :background then add_color("backgroundcolor", value) when :width, :height then add_with_unit(key,value) #when :inkspread then add(key,value) else add(key,value) end end end |
#ps ⇒ Object
201 202 203 204 205 |
# File 'lib/rghost_barcode/rghost_barcode_base.rb', line 201 def ps formated_params=[ @text.map, @border.map, @guard.map, self.map].join(" ") "gsave newpath #{@point.ps} #{@rotate} #{@scale} 0 0 moveto (#{@barcode}) (#{formated_params}) #{@self_name} closepath grestore" end |